Skip to content

Commit

Permalink
refactor: missing-expect-assertions-call rule rename
Browse files Browse the repository at this point in the history
Rename missing-expect-assertions-call to prefer-expect-assertions
  • Loading branch information
tushardhole committed Jan 8, 2018
1 parent af992f6 commit 2f4bc72
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 86 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const preferToBeNull = require('./rules/prefer_to_be_null');
const preferToBeUndefined = require('./rules/prefer_to_be_undefined');
const preferToHaveLength = require('./rules/prefer_to_have_length');
const validExpect = require('./rules/valid_expect');
const missingExpectAssertions = require('./rules/missing_expect_assertions_call');
const preferExpectAssertions = require('./rules/prefer_expect_assertions');

const snapshotProcessor = require('./processors/snapshot-processor');

Expand All @@ -25,7 +25,7 @@ module.exports = {
'jest/no-identical-title': 'error',
'jest/prefer-to-have-length': 'warn',
'jest/valid-expect': 'error',
'jest/missing-expect-assertions-call': 'error',
'jest/prefer-expect-assertions': 'error',
},
},
},
Expand Down Expand Up @@ -64,6 +64,6 @@ module.exports = {
'prefer-to-be-undefined': preferToBeUndefined,
'prefer-to-have-length': preferToHaveLength,
'valid-expect': validExpect,
'missing-expect-assertions-call': missingExpectAssertions,
'prefer-expect-assertions': preferExpectAssertions,
},
};
83 changes: 0 additions & 83 deletions rules/__tests__/missing_expect_assertions_call_test.js

This file was deleted.

79 changes: 79 additions & 0 deletions rules/__tests__/prefer_expect_assertions.test.js
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.

0 comments on commit 2f4bc72

Please # to comment.