1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/prefer-common-expectserror');
const message = 'Please use common.expectsError(fn, err) instead of ' +
'assert.throws(fn, common.expectsError(err)).';
new RuleTester().run('prefer-common-expectserror', rule, {
valid: [
'assert.throws(fn, /[a-z]/)',
'assert.throws(function () {}, function() {})',
'common.expectsError(function() {}, err)'
],
invalid: [
{
code: 'assert.throws(function() {}, common.expectsError(err))',
errors: [{ message }]
},
{
code: 'assert.throws(fn, common.expectsError(err))',
errors: [{ message }]
}
]
});
|