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>
33 lines
674 B
JavaScript
33 lines
674 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
|
|
const RuleTester = require('../../tools/eslint').RuleTester;
|
|
const rule = require('../../tools/eslint-rules/crypto-check');
|
|
|
|
const message = 'Please add a hasCrypto check to allow this test to be ' +
|
|
'skipped when Node is built "--without-ssl".';
|
|
|
|
new RuleTester().run('crypto-check', rule, {
|
|
valid: [
|
|
'foo',
|
|
'crypto',
|
|
`
|
|
if (!common.hasCrypto) {
|
|
common.skip();
|
|
}
|
|
require('crypto');
|
|
`
|
|
],
|
|
invalid: [
|
|
{
|
|
code: 'require("crypto")',
|
|
errors: [{ message }]
|
|
},
|
|
{
|
|
code: 'if (common.foo) {} require("crypto")',
|
|
errors: [{ message }]
|
|
}
|
|
]
|
|
});
|