mirror of
https://github.com/nodejs/node.git
synced 2025-05-05 15:32:15 +00:00

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>
23 lines
830 B
JavaScript
23 lines
830 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
if (!common.hasCrypto) {
|
|
common.skip('missing crypto');
|
|
return;
|
|
}
|
|
const crypto = require('crypto');
|
|
const tls = require('tls');
|
|
|
|
common.expectWarning('DeprecationWarning', [
|
|
'crypto.Credentials is deprecated. Use tls.SecureContext instead.',
|
|
'crypto.createCredentials is deprecated. Use tls.createSecureContext instead.'
|
|
]);
|
|
|
|
// Accessing the deprecated function is enough to trigger the warning event.
|
|
// It does not need to be called. So the assert serves the purpose of both
|
|
// triggering the warning event and confirming that the deprected function is
|
|
// mapped to the correct non-deprecated function.
|
|
assert.strictEqual(crypto.Credentials, tls.SecureContext);
|
|
assert.strictEqual(crypto.createCredentials, tls.createSecureContext);
|