Skip to content

Commit 58daeed

Browse files
committed
test: add test cases
1 parent e6d4168 commit 58daeed

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/lib/rules/prefer-find-by.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,35 @@ ruleTester.run(RULE_NAME, rule, {
689689
const button = await screen.${buildFindByMethod(
690690
queryMethod
691691
)}('Count is: 0', { timeout: 100, interval: 200 })
692+
`,
693+
})),
694+
...ASYNC_QUERIES_COMBINATIONS.map((queryMethod) => ({
695+
code: `
696+
import {waitFor} from '${testingFramework}';
697+
it('tests', async () => {
698+
await waitFor(async () => {
699+
const button = await screen.${queryMethod}("button", { name: "Submit" })
700+
expect(button).toBeInTheDocument()
701+
})
702+
})
703+
`,
704+
errors: [
705+
{
706+
messageId: 'preferFindBy',
707+
data: {
708+
queryVariant: getFindByQueryVariant(queryMethod),
709+
queryMethod: queryMethod.split('By')[1],
710+
prevQuery: queryMethod,
711+
waitForMethodName: 'waitFor',
712+
},
713+
},
714+
],
715+
output: `
716+
import {waitFor} from '${testingFramework}';
717+
it('tests', async () => {
718+
const button = await screen.${queryMethod}("button", { name: "Submit" })
719+
expect(button).toBeInTheDocument()
720+
})
692721
`,
693722
})),
694723
]),

0 commit comments

Comments
 (0)