mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 16:22:29 +00:00

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>
28 lines
643 B
JavaScript
28 lines
643 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
|
|
const RuleTester = require('../../tools/eslint').RuleTester;
|
|
const rule = require('../../tools/eslint-rules/prefer-common-mustnotcall');
|
|
|
|
const message = 'Please use common.mustNotCall(msg) instead of ' +
|
|
'common.mustCall(fn, 0) or common.mustCall(0).';
|
|
|
|
new RuleTester().run('prefer-common-mustnotcall', rule, {
|
|
valid: [
|
|
'common.mustNotCall(fn)',
|
|
'common.mustCall(fn)',
|
|
'common.mustCall(fn, 1)'
|
|
],
|
|
invalid: [
|
|
{
|
|
code: 'common.mustCall(fn, 0)',
|
|
errors: [{ message }]
|
|
},
|
|
{
|
|
code: 'common.mustCall(0)',
|
|
errors: [{ message }]
|
|
}
|
|
]
|
|
});
|