Skip to content

Commit

Permalink
feat(rule-tester): add tests with empty valid and invalid suites
Browse files Browse the repository at this point in the history
  • Loading branch information
azat-io committed Sep 3, 2023
1 parent 9af968f commit 2f683f8
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/rule-tester/tests/RuleTester.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,37 @@ describe('RuleTester', () => {
expect(mockedDescribeSkip.mock.calls).toHaveLength(0);
// expect(mockedIt.mock.lastCall).toMatchInlineSnapshot(`undefined`);
});

it('does not call describe with valid if no valid tests are provided', () => {
const ruleTester = new RuleTester();

ruleTester.run('my-rule', NOOP_RULE, {
valid: [],
invalid: [
{
code: 'invalid',
errors: [{ messageId: 'error' }],
},
],
});

expect(mockedDescribe.mock.calls).toHaveLength(2);
});

it('does not call describe with invalid if no invalid tests are provided', () => {
const ruleTester = new RuleTester();

ruleTester.run('my-rule', NOOP_RULE, {
valid: [
{
code: 'valid',
},
],
invalid: [],
});

expect(mockedDescribe.mock.calls).toHaveLength(2);
});
});
});
});

0 comments on commit 2f683f8

Please sign in to comment.