mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
cd5ee52d70
This adds tests for the custom eslint rules in this repository, using the `RuleTester` test utility bundled with eslint. PR-URL: https://github.com/nodejs/node/pull/16138 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: James M Snell <jasnell@gmail.com>
38 lines
892 B
JavaScript
38 lines
892 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
|
|
const RuleTester = require('../../tools/eslint').RuleTester;
|
|
const rule = require('../../tools/eslint-rules/prefer-assert-methods');
|
|
|
|
new RuleTester().run('prefer-assert-methods', rule, {
|
|
valid: [
|
|
'assert.strictEqual(foo, bar)',
|
|
'assert(foo === bar && baz)'
|
|
],
|
|
invalid: [
|
|
{
|
|
code: 'assert(foo == bar)',
|
|
errors: [{ message: "'assert.equal' should be used instead of '=='" }]
|
|
},
|
|
{
|
|
code: 'assert(foo === bar)',
|
|
errors: [{
|
|
message: "'assert.strictEqual' should be used instead of '==='"
|
|
}]
|
|
},
|
|
{
|
|
code: 'assert(foo != bar)',
|
|
errors: [{
|
|
message: "'assert.notEqual' should be used instead of '!='"
|
|
}]
|
|
},
|
|
{
|
|
code: 'assert(foo !== bar)',
|
|
errors: [{
|
|
message: "'assert.notStrictEqual' should be used instead of '!=='"
|
|
}]
|
|
},
|
|
]
|
|
});
|