Skip to content

Commit aaee1b2

Browse files
committed
test(prefer-presence-queries): improve existing invalid tests
1 parent c880f2f commit aaee1b2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tests/lib/rules/prefer-presence-queries.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ const getInvalidAssertion = (
3131
) =>
3232
allQueryUseInAssertion(query).map((query) => ({
3333
code: `expect(${query}('Hello'))${matcher}`,
34-
errors: [{ messageId }],
34+
// TODO: column can't be checked as queries are generated with and without `screen` prefix
35+
// so this must be generated in a different way to be able to check error column.
36+
errors: [{ messageId, line: 1 }],
3537
}));
3638

3739
ruleTester.run(RULE_NAME, rule, {
@@ -152,8 +154,9 @@ ruleTester.run(RULE_NAME, rule, {
152154
[]
153155
),
154156
{
157+
// TODO: improve this case to get error on `queryAllByText` rather than `screen`
155158
code: 'expect(screen.getAllByText("button")[1]).not.toBeInTheDocument()',
156-
errors: [{ messageId: 'absenceQuery' }],
159+
errors: [{ messageId: 'absenceQuery', line: 1, column: 15 }],
157160
},
158161
...queryByQueries.reduce(
159162
(validRules, queryName) => [
@@ -186,8 +189,10 @@ ruleTester.run(RULE_NAME, rule, {
186189
[]
187190
),
188191
{
192+
// TODO: improve this case to get error on `queryAllByText` rather than `screen`
189193
code: 'expect(screen.queryAllByText("button")[1]).toBeInTheDocument()',
190-
errors: [{ messageId: 'presenceQuery' }],
194+
errors: [{ messageId: 'presenceQuery', line: 1, column: 15 }],
191195
},
196+
// TODO: add more tests for custom queries
192197
],
193198
});

0 commit comments

Comments
 (0)