Skip to content

Commit

Permalink
test: add new cases
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Jun 4, 2023
1 parent 32d7ed3 commit 5ddce16
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/__tests__/__fixtures__/createBannedAttributeTestCases.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ export default ({ preferred, negatedPreferred, attribute }) => {
],
output: `const el = screen.getByText("foo"); expect(el).${negatedPreferred}`,
},
{
code: `const el = screen.getByRole("button"); expect(el).not.${preferred}`,
errors: [
{
message: `Use ${negatedPreferred} instead of not.${preferred}`,
},
],
output: `const el = screen.getByRole("button"); expect(el).${negatedPreferred}`,
},
]
: [];
const directChecks = /-/.test(attribute)
Expand All @@ -63,13 +72,22 @@ export default ({ preferred, negatedPreferred, attribute }) => {
output: `expect(getByText('foo')).${[negatedPreferred]}`,
},
{
code: `expect(getByText('foo').${attribute}).toBe(true)`,
code: `const el = getByText('foo'); expect(el.${attribute}).toBe(true)`,
errors: [
{
message: `Use ${preferred} instead of checking .${attribute} directly`,
},
],
output: `expect(getByText('foo')).${[preferred]}`,
output: `const el = getByText('foo'); expect(el).${[preferred]}`,
},
{
code: `const el = getByRole('button'); expect(el.${attribute}).toBe(true)`,
errors: [
{
message: `Use ${preferred} instead of checking .${attribute} directly`,
},
],
output: `const el = getByRole('button'); expect(el).${[preferred]}`,
},
];

Expand Down Expand Up @@ -203,6 +221,14 @@ export default ({ preferred, negatedPreferred, attribute }) => {
},
],
},
{
code: `const el = getByRole("button", { name: 'My Button' }); expect(el).toHaveProperty('${attribute}', foo)`,
errors: [
{
message: `Use ${preferred} instead of toHaveProperty('${attribute}', foo)`,
},
],
},
],
};
};

0 comments on commit 5ddce16

Please sign in to comment.