Skip to content

Commit

Permalink
test(prefer-comparison-matcher): update names and remove duplicates (#…
Browse files Browse the repository at this point in the history
…1540)

* test(prefer-comparison-matcher): update test names

* test(prefer-comparison-matcher): deduplicate examples
  • Loading branch information
G-Rath committed Mar 29, 2024
1 parent fb800db commit 8bba541
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/rules/__tests__/prefer-comparison-matcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,38 +205,38 @@ const generateValidStringLiteralCases = (operator: string, matcher: string) => {
['x', "'y'"],
['x', '`y`'],
['x', '`y${z}`'],
].reduce((cases, [a, b]) => [
...cases,
...[
`expect(${a} ${operator} ${b}).${matcher}(true)`,
`expect(${a} ${operator} ${b}).${matcher}(false)`,
`expect(${a} ${operator} ${b}).not.${matcher}(true)`,
`expect(${a} ${operator} ${b}).not.${matcher}(false)`,
`expect(${b} ${operator} ${a}).${matcher}(true)`,
`expect(${b} ${operator} ${a}).${matcher}(false)`,
`expect(${b} ${operator} ${a}).not.${matcher}(true)`,
`expect(${b} ${operator} ${a}).not.${matcher}(false)`,
`expect(${a} ${operator} ${b}).${matcher}(true)`,
`expect(${a} ${operator} ${b}).${matcher}(false)`,
`expect(${a} ${operator} ${b}).not.${matcher}(true)`,
`expect(${a} ${operator} ${b}).not.${matcher}(false)`,
`expect(${b} ${operator} ${a}).${matcher}(true)`,
`expect(${b} ${operator} ${a}).${matcher}(false)`,
`expect(${b} ${operator} ${a}).not.${matcher}(true)`,
`expect(${b} ${operator} ${a}).not.${matcher}(false)`,
`expect(${b} ${operator} ${b}).not.${matcher}(false)`,
`expect(${b} ${operator} ${b}).resolves.not.${matcher}(false)`,
`expect(${b} ${operator} ${b}).resolves.${matcher}(false)`,
].reduce(
(cases, [a, b]) => [
...cases,
...[
`expect(${a} ${operator} ${b}).${matcher}(true)`,
`expect(${a} ${operator} ${b}).${matcher}(false)`,
`expect(${a} ${operator} ${b}).not.${matcher}(true)`,
`expect(${a} ${operator} ${b}).not.${matcher}(false)`,
`expect(${a} ${operator} ${b}).resolves.${matcher}(true)`,
`expect(${a} ${operator} ${b}).resolves.${matcher}(false)`,
`expect(${a} ${operator} ${b}).resolves.not.${matcher}(true)`,
`expect(${a} ${operator} ${b}).resolves.not.${matcher}(false)`,
`expect(${b} ${operator} ${a}).resolves.not.${matcher}(false)`,
`expect(${b} ${operator} ${a}).resolves.not.${matcher}(true)`,
`expect(${b} ${operator} ${a}).resolves.${matcher}(false)`,
`expect(${b} ${operator} ${a}).resolves.${matcher}(true)`,
`expect(${b} ${operator} ${a}).not.${matcher}(false)`,
`expect(${b} ${operator} ${a}).not.${matcher}(true)`,
`expect(${b} ${operator} ${a}).${matcher}(false)`,
`expect(${b} ${operator} ${a}).${matcher}(true)`,
],
],
]);
[],
);
};

const testComparisonOperator = (
operator: string,
preferredMatcher: string,
preferredMatcherWhenNegated: string,
) => {
ruleTester.run(`prefer-to-be-comparison: ${operator}`, rule, {
ruleTester.run(`prefer-comparison-matcher: ${operator}`, rule, {
valid: [
'expect()',
'expect({}).toStrictEqual({})',
Expand Down Expand Up @@ -274,7 +274,7 @@ testComparisonOperator('<', 'toBeLessThan', 'toBeGreaterThanOrEqual');
testComparisonOperator('>=', 'toBeGreaterThanOrEqual', 'toBeLessThan');
testComparisonOperator('<=', 'toBeLessThanOrEqual', 'toBeGreaterThan');

ruleTester.run(`prefer-to-be-comparison`, rule, {
ruleTester.run(`prefer-comparison-matcher`, rule, {
valid: [
'expect.hasAssertions',
'expect.hasAssertions()',
Expand Down

0 comments on commit 8bba541

Please sign in to comment.