Skip to content

Commit 59dfaf1

Browse files
committed
test(prefer-screen-queries): add another test case
1 parent 0be38be commit 59dfaf1

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

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

+40-3
Original file line numberDiff line numberDiff line change
@@ -414,19 +414,56 @@ ruleTester.run(RULE_NAME, rule, {
414414
} as const)
415415
),
416416
{
417-
code: ` // issue #367
417+
code: ` // issue #367 - example A
418418
import { render } from '@testing-library/react';
419419
420420
function setup() {
421421
return render(<div />);
422422
}
423423
424-
it('undetected 1', () => {
424+
it('foo', async () => {
425+
const { getByText } = await setup();
426+
expect(getByText('foo')).toBeInTheDocument();
427+
});
428+
429+
it('bar', () => {
430+
const { getByText } = setup();
431+
expect(getByText('foo')).toBeInTheDocument();
432+
});
433+
`,
434+
errors: [
435+
{
436+
messageId: 'preferScreenQueries',
437+
line: 10,
438+
column: 16,
439+
data: {
440+
name: 'getByText',
441+
},
442+
},
443+
{
444+
messageId: 'preferScreenQueries',
445+
line: 15,
446+
column: 16,
447+
data: {
448+
name: 'getByText',
449+
},
450+
},
451+
],
452+
},
453+
{
454+
code: ` // issue #367 - example B
455+
import { render } from '@testing-library/react';
456+
457+
function setup() {
458+
return render(<div />);
459+
}
460+
461+
it('foo', () => {
425462
const { getByText } = setup();
426463
expect(getByText('foo')).toBeInTheDocument();
427464
});
428465
429-
it('undetected 2', () => {
466+
it('bar', () => {
430467
const results = setup();
431468
const { getByText } = results;
432469
expect(getByText('foo')).toBe('foo');

0 commit comments

Comments
 (0)