-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: missing-expect-assertions-call rule rename
Rename missing-expect-assertions-call to prefer-expect-assertions
- Loading branch information
1 parent
af992f6
commit 2f4bc72
Showing
4 changed files
with
82 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
'use strict'; | ||
|
||
const RuleTester = require('eslint').RuleTester; | ||
const rules = require('../..').rules; | ||
|
||
const ruleTester = new RuleTester(); | ||
const expectedMsg = | ||
"Every test should have either `expect.assertions(<number of assertions>)` or `expect.hasAssertions()` as it's first expression"; | ||
|
||
ruleTester.run('prefer-expect-assertions', rules['prefer-expect-assertions'], { | ||
invalid: [ | ||
{ | ||
code: 'it("it1", () => { foo()})', | ||
errors: [ | ||
{ | ||
message: expectedMsg, | ||
}, | ||
], | ||
parserOptions: { ecmaVersion: 6 }, | ||
}, | ||
{ | ||
code: | ||
'it("it1", function() {' + | ||
'\n\t\t\tsomeFunctionToDo();' + | ||
'\n\t\t\tsomeFunctionToDo2();\n' + | ||
'\t\t\t})', | ||
errors: [ | ||
{ | ||
message: expectedMsg, | ||
}, | ||
], | ||
}, | ||
{ | ||
code: 'it("it1", function() {var a = 2;})', | ||
errors: [ | ||
{ | ||
message: expectedMsg, | ||
}, | ||
], | ||
}, | ||
{ | ||
code: 'it("it1", function() {expect.assertions();})', | ||
errors: [ | ||
{ | ||
message: expectedMsg, | ||
}, | ||
], | ||
}, | ||
{ | ||
code: 'it("it1", function() {expect.assertions(1,2);})', | ||
errors: [ | ||
{ | ||
message: expectedMsg, | ||
}, | ||
], | ||
}, | ||
{ | ||
code: 'it("it1", function() {expect.assertions("1");})', | ||
errors: [ | ||
{ | ||
message: expectedMsg, | ||
}, | ||
], | ||
}, | ||
], | ||
|
||
valid: [ | ||
{ | ||
code: 'test("it1", () => {expect.assertions(0);})', | ||
parserOptions: { ecmaVersion: 6 }, | ||
}, | ||
'test("it1", function() {expect.assertions(0);})', | ||
'test("it1", function() {expect.hasAssertions();})', | ||
'it("it1", function() {expect.assertions(0);})', | ||
'it("it1", function() {\n\t\t\texpect.assertions(1);' + | ||
'\n\t\t\texpect(someValue).toBe(true)\n' + | ||
'\t\t\t})', | ||
], | ||
}); |
File renamed without changes.