Skip to content

Commit

Permalink
fix: add argument node checks
Browse files Browse the repository at this point in the history
Closes #29
  • Loading branch information
xfumihiro authored and SimenB committed Dec 5, 2017
1 parent e7e9e62 commit 775e75d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rules/__tests__/prefer_to_be_null.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const rules = require('../../').rules;
const ruleTester = new RuleTester();

ruleTester.run('prefer_to_be_null', rules['prefer-to-be-null'], {
valid: ['expect(null).toBeNull();'],
valid: ['expect(null).toBeNull();', 'expect(null).toEqual();'],

invalid: [
{
Expand Down
4 changes: 4 additions & 0 deletions rules/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,26 @@ const expectToBeCase = (node, arg) =>
!(expectNotCase(node) || expectResolveCase(node) || expectRejectCase(node)) &&
expectCase(node) &&
methodName(node) === 'toBe' &&
argument(node) &&
argument(node).value === arg;

const expectNotToBeCase = (node, arg) =>
expectNotCase(node) &&
methodName2(node) === 'toBe' &&
argument2(node) &&
argument2(node).value === arg;

const expectToEqualCase = (node, arg) =>
!(expectNotCase(node) || expectResolveCase(node) || expectRejectCase(node)) &&
expectCase(node) &&
methodName(node) === 'toEqual' &&
argument(node) &&
argument(node).value === arg;

const expectNotToEqualCase = (node, arg) =>
expectNotCase(node) &&
methodName2(node) === 'toEqual' &&
argument2(node) &&
argument2(node).value === arg;

const expectToBeUndefinedCase = node =>
Expand Down

0 comments on commit 775e75d

Please sign in to comment.