Skip to content

Commit 7673c54

Browse files
xfumihiroSimenB
authored andcommitted
fix: add argument node checks
Closes #29
1 parent e7e9e62 commit 7673c54

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

rules/__tests__/prefer_to_be_null.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const rules = require('../../').rules;
66
const ruleTester = new RuleTester();
77

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

1111
invalid: [
1212
{

rules/util.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,26 @@ const expectToBeCase = (node, arg) =>
2626
!(expectNotCase(node) || expectResolveCase(node) || expectRejectCase(node)) &&
2727
expectCase(node) &&
2828
methodName(node) === 'toBe' &&
29+
argument(node) &&
2930
argument(node).value === arg;
3031

3132
const expectNotToBeCase = (node, arg) =>
3233
expectNotCase(node) &&
3334
methodName2(node) === 'toBe' &&
35+
argument2(node) &&
3436
argument2(node).value === arg;
3537

3638
const expectToEqualCase = (node, arg) =>
3739
!(expectNotCase(node) || expectResolveCase(node) || expectRejectCase(node)) &&
3840
expectCase(node) &&
3941
methodName(node) === 'toEqual' &&
42+
argument(node) &&
4043
argument(node).value === arg;
4144

4245
const expectNotToEqualCase = (node, arg) =>
4346
expectNotCase(node) &&
4447
methodName2(node) === 'toEqual' &&
48+
argument2(node) &&
4549
argument2(node).value === arg;
4650

4751
const expectToBeUndefinedCase = node =>

0 commit comments

Comments
 (0)