Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions test/fixtures/basic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

var deprecate = require('../..')('basic')

var object = { foo: 'bar' }
deprecate.property(object, 'foo')

function fn () {}
deprecate.function(fn)
29 changes: 26 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ var script = path.join(__dirname, 'fixtures', 'script.js')
var spawn = require('child_process').spawn
var strictlib = libs.strict

function isNodeVersionGE (required) {
var nodeVersion = process.version.substr(1).split('.')
for (var i = 0; i < required.length; i++) {
if (+nodeVersion[i] < required[i]) {
return false
}
}
return true
}

describe('depd(namespace)', function () {
it('creates deprecated function', function () {
assert.strictEqual(typeof depd('test'), 'function')
Expand Down Expand Up @@ -730,9 +740,9 @@ describe('node script.js', function () {
;(function () {
// --*-deprecation switches are 0.8+
// no good way to feature detect this sync
var describe = /^v0\.6\./.test(process.version)
? global.describe.skip
: global.describe
var describe = isNodeVersionGE([0, 8])
? global.describe
: global.describe.skip

describe('node --no-deprecation script.js', function () {
it('should suppress deprecation message', function (done) {
Expand All @@ -755,6 +765,19 @@ describe('node script.js', function () {
})
}())

describe('node --disallow-code-generation-from-strings script.js', function () {
it('should run without error', function (done) {
if (!isNodeVersionGE([9])) this.skip() // --disallow-code-generation-from-strings is 9+

var basic = path.join(__dirname, 'fixtures', 'basic.js')
captureChildStderr(basic, ['--disallow-code-generation-from-strings'], function (err, stderr) {
if (err) return done(err)
assert.strictEqual(stderr, '')
done()
})
})
})

function captureChildStderr (script, opts, callback) {
var chunks = []
var env = { PATH: process.env.PATH }
Expand Down