Skip to content

Commit bdc3506

Browse files
committed
test: update no-node-access tests to include userEvent setup scenarios
1 parent d445ec2 commit bdc3506

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

tests/lib/rules/no-node-access.test.ts

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import rule, {
55
Options,
66
MessageIds,
77
} from '../../../lib/rules/no-node-access';
8-
import { EVENT_HANDLER_METHODS, EVENTS_SIMULATORS } from '../../../lib/utils';
8+
import { EVENT_HANDLER_METHODS } from '../../../lib/utils';
99
import { createRuleTester } from '../test-utils';
1010

1111
const ruleTester = createRuleTester();
@@ -173,14 +173,42 @@ ruleTester.run(RULE_NAME, rule, {
173173
user.click(buttonText);
174174
`,
175175
},
176-
...EVENTS_SIMULATORS.map((simulator) => ({
176+
{
177+
code: `
178+
import userEvent from '@testing-library/user-event';
179+
import { screen } from '${testingFramework}';
180+
181+
const buttonText = screen.getByText('submit');
182+
const userAlias = userEvent.setup();
183+
userAlias.click(buttonText);
184+
`,
185+
},
186+
{
187+
code: `
188+
import userEvent from '@testing-library/user-event';
189+
import { screen } from '${testingFramework}';
190+
191+
const buttonText = screen.getByText('submit');
192+
userEvent.setup().click(buttonText);
193+
`,
194+
},
195+
{
177196
code: `
197+
import userEvt from '@testing-library/user-event';
178198
import { screen } from '${testingFramework}';
179199
180200
const buttonText = screen.getByText('submit');
181-
${simulator}.click(buttonText);
201+
userEvt.click(buttonText);
202+
`,
203+
},
204+
{
205+
code: `
206+
import { screen, fireEvent as fe } from '${testingFramework}';
207+
208+
const buttonText = screen.getByText('submit');
209+
fe.click(buttonText);
182210
`,
183-
})),
211+
},
184212
]
185213
),
186214
invalid: SUPPORTED_TESTING_FRAMEWORKS.flatMap((testingFramework) => [

0 commit comments

Comments
 (0)