From 8e4133a910dda7798c6a226b5b3a6b348d226976 Mon Sep 17 00:00:00 2001 From: Guillaume Martigny Date: Wed, 24 Mar 2021 15:57:47 +0100 Subject: [PATCH] Review --- readme.md | 2 +- test/no-error-ctor-with-notthrows.js | 41 ++++++++++++++-------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/readme.md b/readme.md index f4a0c1ad..84a317da 100644 --- a/readme.md +++ b/readme.md @@ -83,7 +83,7 @@ The rules will only activate in test files. - [no-async-fn-without-await](docs/rules/no-async-fn-without-await.md) - Ensure that async tests use `await`. - [no-cb-test](docs/rules/no-cb-test.md) - Ensure no `test.cb()` is used. - [no-duplicate-modifiers](docs/rules/no-duplicate-modifiers.md) - Ensure tests do not have duplicate modifiers. -- [no-error-ctor-with-notthrows](docs/rules/no-error-ctor-with-notthrows.md) - No specifying error type in `t.notThrows()`. +- [no-error-ctor-with-notthrows](docs/rules/no-error-ctor-with-notthrows.md) - Ensure no error constructor is specified in `t.notThrows()`. - [no-identical-title](docs/rules/no-identical-title.md) - Ensure no tests have the same title. - [no-ignored-test-files](docs/rules/no-ignored-test-files.md) - Ensure no tests are written in ignored files. - [no-import-test-files](docs/rules/no-import-test-files.md) - Ensure no test files are imported anywhere. diff --git a/test/no-error-ctor-with-notthrows.js b/test/no-error-ctor-with-notthrows.js index 17453140..cbda38f3 100644 --- a/test/no-error-ctor-with-notthrows.js +++ b/test/no-error-ctor-with-notthrows.js @@ -13,12 +13,12 @@ const ruleTester = avaRuleTester(test, { const errors = [{ruleId: 'no-error-ctor-with-notthrows'}]; -const header = `const test = require('ava');\n`; // eslint-disable-line quotes +const header = 'const test = require(\'ava\');\n'; ruleTester.run('no-error-ctor-with-notthrows', rule, { valid: [ `${header} - test('some test',t => { + test('some test', t => { t.notThrows(() => { t.pass(); }); @@ -39,32 +39,31 @@ ruleTester.run('no-error-ctor-with-notthrows', rule, { });`, `${header} - test(t => { - t.end(); })`, + test(t => { t.end(); })`, `${header} - test('some test',t => { + test('some test', t => { t.notThrows(() => { t.pass(); }, true); });`, `${header} - test('some test',t => { + test('some test', t => { t.notThrows(() => { t.pass(); }, 'some string'); });`, `${header} - test('some test',t => { + test('some test', t => { t.notThrows(() => { t.pass(); }, {firstName:'some', lastName: 'object'}); });`, `${header} - test('some test',t => { + test('some test', t => { t.notThrowsAsync(() => { t.pass(); }); @@ -78,19 +77,19 @@ ruleTester.run('no-error-ctor-with-notthrows', rule, { });`, `${header} - test('some test',t => { + test('some test', t => { t.notThrowsAsync(() => { t.pass(); }, {firstName:'some', lastName: 'object'}); });`, `${header} - test('some test',t => { + test('some test', t => { notThrows(foo); });`, `${header} - test('some test',t => { + test('some test', t => { myCustomNotThrows.notThrows(foo); });`, @@ -100,7 +99,7 @@ ruleTester.run('no-error-ctor-with-notthrows', rule, { }, void 0);`, // Shouldn't be triggered since it's not a test file - `test('some test',t => { + `test('some test', t => { t.notThrowsAsync(() => { t.pass(); }, TypeError); @@ -118,7 +117,7 @@ ruleTester.run('no-error-ctor-with-notthrows', rule, { }, { code: `${header} - test('some test',t => { + test('some test', t => { t.notThrows(() => { t.pass(); }, TypeError); @@ -136,7 +135,7 @@ ruleTester.run('no-error-ctor-with-notthrows', rule, { }, { code: `${header} - test('some test',t => { + test('some test', t => { t.notThrowsAsync(() => { t.pass(); }, TypeError); @@ -145,7 +144,7 @@ ruleTester.run('no-error-ctor-with-notthrows', rule, { }, { code: `${header} - test('some test',t => { + test('some test', t => { t.notThrowsAsync(() => { t.pass(); }, Error); @@ -154,7 +153,7 @@ ruleTester.run('no-error-ctor-with-notthrows', rule, { }, { code: `${header} - test('some test',t => { + test('some test', t => { t.notThrowsAsync(() => { t.pass(); }, SyntaxError); @@ -163,7 +162,7 @@ ruleTester.run('no-error-ctor-with-notthrows', rule, { }, { code: `${header} - test('some test',t => { + test('some test', t => { t.notThrowsAsync(() => { t.pass(); }, AssertionError); @@ -172,7 +171,7 @@ ruleTester.run('no-error-ctor-with-notthrows', rule, { }, { code: `${header} - test('some test',t => { + test('some test', t => { t.notThrowsAsync(() => { t.pass(); }, ReferenceError); @@ -181,7 +180,7 @@ ruleTester.run('no-error-ctor-with-notthrows', rule, { }, { code: `${header} - test('some test',t => { + test('some test', t => { t.notThrowsAsync(() => { t.pass(); }, RangeError); @@ -190,7 +189,7 @@ ruleTester.run('no-error-ctor-with-notthrows', rule, { }, { code: `${header} - test('some test',t => { + test('some test', t => { t.notThrowsAsync(() => { t.pass(); }, SystemError); @@ -199,7 +198,7 @@ ruleTester.run('no-error-ctor-with-notthrows', rule, { }, { code: `${header} - test('some test',t => { + test('some test', t => { t.notThrowsAsync(() => { t.pass(); }, $DOMError);