node/test/parallel/test-buffer-pending-deprecation.js
Rich Trott 75bfdad037 test: check that pending warning is emitted once
Code for the new --pending-deprecation flag contains logic to make sure
the deprecation warning is emitted only once. However, this was not
being tested. Add test coverage for this situation.

PR-URL: https://github.com/nodejs/node/pull/12527
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-04-24 14:14:24 -07:00

22 lines
737 B
JavaScript

// Flags: --pending-deprecation --no-warnings
'use strict';
const common = require('../common');
const Buffer = require('buffer').Buffer;
const bufferWarning = 'The Buffer() and new Buffer() constructors are not ' +
'recommended for use due to security and usability ' +
'concerns. Please use the new Buffer.alloc(), ' +
'Buffer.allocUnsafe(), or Buffer.from() construction ' +
'methods instead.';
common.expectWarning('DeprecationWarning', bufferWarning);
// This is used to make sure that a warning is only emitted once even though
// `new Buffer()` is called twice.
process.on('warning', common.mustCall());
new Buffer(10);
new Buffer(10);