diff options
author | Teddy Katz <teddy.katz@gmail.com> | 2017-10-11 01:42:47 -0400 |
---|---|---|
committer | Teddy Katz <teddy.katz@gmail.com> | 2017-10-14 02:53:19 -0400 |
commit | cd5ee52d70889a39f8251eb7d49f8063f96f2d8c (patch) | |
tree | b71c5390e7b254c1d1a1af2c031033bc63f2fb1f /test/parallel/test-eslint-crypto-check.js | |
parent | 34c47ed4867e0bbde3ad55557bd265238d4ac91f (diff) | |
download | android-node-v8-cd5ee52d70889a39f8251eb7d49f8063f96f2d8c.tar.gz android-node-v8-cd5ee52d70889a39f8251eb7d49f8063f96f2d8c.tar.bz2 android-node-v8-cd5ee52d70889a39f8251eb7d49f8063f96f2d8c.zip |
test: add tests for eslint rules
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>
Diffstat (limited to 'test/parallel/test-eslint-crypto-check.js')
-rw-r--r-- | test/parallel/test-eslint-crypto-check.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/parallel/test-eslint-crypto-check.js b/test/parallel/test-eslint-crypto-check.js new file mode 100644 index 0000000000..102560e78e --- /dev/null +++ b/test/parallel/test-eslint-crypto-check.js @@ -0,0 +1,32 @@ +'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 }] + } + ] +}); |