mirror of https://github.com/lukechilds/node.git
Browse Source
There are multiple tests that use the same boilerplate to test that warnings are correctly emitted. This adds a new common function to do that and changes the tests to use it. PR-URL: https://github.com/nodejs/node/pull/8662 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>v6
5 changed files with 20 additions and 41 deletions
@ -1,17 +1,11 @@ |
|||||
'use strict'; |
'use strict'; |
||||
const common = require('../common'); |
const common = require('../common'); |
||||
const assert = require('assert'); |
|
||||
|
|
||||
const expected = |
const expected = |
||||
'Using Buffer without `new` will soon stop working. ' + |
'Using Buffer without `new` will soon stop working. ' + |
||||
'Use `new Buffer()`, or preferably ' + |
'Use `new Buffer()`, or preferably ' + |
||||
'`Buffer.from()`, `Buffer.allocUnsafe()` or `Buffer.alloc()` instead.'; |
'`Buffer.from()`, `Buffer.allocUnsafe()` or `Buffer.alloc()` instead.'; |
||||
|
common.expectWarning('DeprecationWarning', expected); |
||||
process.on('warning', common.mustCall((warning) => { |
|
||||
assert.strictEqual(warning.name, 'DeprecationWarning'); |
|
||||
assert.strictEqual(warning.message, expected, |
|
||||
`unexpected error message: "${warning.message}"`); |
|
||||
}, 1)); |
|
||||
|
|
||||
Buffer(1); |
Buffer(1); |
||||
Buffer(1); |
Buffer(1); |
||||
|
Loading…
Reference in new issue