test: don't hard code deprecation count · nodejs/node@c52a973

@@ -9,19 +9,19 @@ if (!common.hasCrypto) {

99

const crypto = require('crypto');

1010

const tls = require('tls');

111112+

const expected = [

13+

'crypto.Credentials is deprecated. Use tls.SecureContext instead.',

14+

'crypto.createCredentials is deprecated. Use tls.createSecureContext instead.'

15+

];

16+1217

process.on('warning', common.mustCall((warning) => {

1318

assert.strictEqual(warning.name, 'DeprecationWarning');

1419

assert.notStrictEqual(expected.indexOf(warning.message), -1,

1520

`unexpected error message: "${warning.message}"`);

1621

// Remove a warning message after it is seen so that we guarantee that we get

1722

// each message only once.

1823

expected.splice(expected.indexOf(warning.message), 1);

19-

}, 2));

20-21-

var expected = [

22-

'crypto.Credentials is deprecated. Use tls.SecureContext instead.',

23-

'crypto.createCredentials is deprecated. Use tls.createSecureContext instead.'

24-

];

24+

}, expected.length));

25252626

// Accessing the deprecated function is enough to trigger the warning event.

2727

// It does not need to be called. So the assert serves the purpose of both