summaryrefslogtreecommitdiff
path: root/test/parallel/test-eslint-prefer-assert-methods.js
diff options
context:
space:
mode:
authorTeddy Katz <teddy.katz@gmail.com>2017-10-11 01:42:47 -0400
committerTeddy Katz <teddy.katz@gmail.com>2017-10-14 02:53:19 -0400
commitcd5ee52d70889a39f8251eb7d49f8063f96f2d8c (patch)
treeb71c5390e7b254c1d1a1af2c031033bc63f2fb1f /test/parallel/test-eslint-prefer-assert-methods.js
parent34c47ed4867e0bbde3ad55557bd265238d4ac91f (diff)
downloadandroid-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-prefer-assert-methods.js')
-rw-r--r--test/parallel/test-eslint-prefer-assert-methods.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/parallel/test-eslint-prefer-assert-methods.js b/test/parallel/test-eslint-prefer-assert-methods.js
new file mode 100644
index 0000000000..2129c08322
--- /dev/null
+++ b/test/parallel/test-eslint-prefer-assert-methods.js
@@ -0,0 +1,37 @@
+'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 '!=='"
+ }]
+ },
+ ]
+});