Skip to content

Commit cc11827

Browse files
committed
test: prefer-screen-queries
1 parent 101485b commit cc11827

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

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

+26-6
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,26 @@ ruleTester.run(RULE_NAME, rule, {
266266
],
267267
} as const)
268268
),
269+
...ALL_QUERIES_COMBINATIONS.map(
270+
(queryMethod) =>
271+
({
272+
settings: { 'testing-library/utils-module': 'test-utils' },
273+
code: `
274+
import { render as testingLibraryRender} from '@marko/testing-library'
275+
const { ${queryMethod} } = testingLibraryRender(foo)
276+
${queryMethod}()`,
277+
errors: [
278+
{
279+
line: 4,
280+
column: 9,
281+
messageId: 'preferScreenQueries',
282+
data: {
283+
name: queryMethod,
284+
},
285+
},
286+
],
287+
} as const)
288+
),
269289
...ALL_QUERIES_COMBINATIONS.map(
270290
(queryMethod) =>
271291
({
@@ -416,16 +436,16 @@ ruleTester.run(RULE_NAME, rule, {
416436
{
417437
code: ` // issue #367 - example A
418438
import { render } from '@testing-library/react';
419-
439+
420440
function setup() {
421441
return render(<div />);
422442
}
423-
443+
424444
it('foo', async () => {
425445
const { getByText } = await setup();
426446
expect(getByText('foo')).toBeInTheDocument();
427447
});
428-
448+
429449
it('bar', () => {
430450
const { getByText } = setup();
431451
expect(getByText('foo')).toBeInTheDocument();
@@ -453,16 +473,16 @@ ruleTester.run(RULE_NAME, rule, {
453473
{
454474
code: ` // issue #367 - example B
455475
import { render } from '@testing-library/react';
456-
476+
457477
function setup() {
458478
return render(<div />);
459479
}
460-
480+
461481
it('foo', () => {
462482
const { getByText } = setup();
463483
expect(getByText('foo')).toBeInTheDocument();
464484
});
465-
485+
466486
it('bar', () => {
467487
const results = setup();
468488
const { getByText } = results;

0 commit comments

Comments
 (0)