Skip to content

Commit 3042446

Browse files
committed
test: cleanup tests
1 parent 86a1a49 commit 3042446

File tree

4 files changed

+51
-41
lines changed

4 files changed

+51
-41
lines changed

tests/lib/rules/no-await-sync-events.test.ts

+51-38
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ const FIRE_EVENT_FUNCTIONS = [
8888
'gotPointerCapture',
8989
'lostPointerCapture',
9090
];
91+
const SUPPORTED_TESTING_FRAMEWORKS = [
92+
'@testing-library/dom',
93+
'@testing-library/angular',
94+
'@testing-library/react',
95+
'@testing-library/vue',
96+
'@marko/testing-library',
97+
];
9198
const USER_EVENT_SYNC_FUNCTIONS = [
9299
'clear',
93100
'click',
@@ -168,15 +175,17 @@ ruleTester.run(RULE_NAME, rule, {
168175
},
169176

170177
// valid tests for fire-event when only user-event set in eventModules
171-
...FIRE_EVENT_FUNCTIONS.map((func) => ({
172-
code: `
173-
import { fireEvent } from '@testing-library/framework';
174-
test('should not report fireEvent.${func} sync event awaited', async() => {
175-
await fireEvent.${func}('foo');
176-
});
177-
`,
178-
options: [{ eventModules: ['user-event'] }],
179-
})),
178+
...SUPPORTED_TESTING_FRAMEWORKS.flatMap((testingFramework) =>
179+
FIRE_EVENT_FUNCTIONS.map((func) => ({
180+
code: `
181+
import { fireEvent } from '@testing-library/${testingFramework}';
182+
test('should not report fireEvent.${func} sync event awaited', async() => {
183+
await fireEvent.${func}('foo');
184+
});
185+
`,
186+
options: [{ eventModules: ['user-event'] }],
187+
}))
188+
),
180189

181190
// valid tests for user-event when only fire-event set in eventModules
182191
...USER_EVENT_SYNC_FUNCTIONS.map((func) => ({
@@ -192,24 +201,26 @@ ruleTester.run(RULE_NAME, rule, {
192201

193202
invalid: [
194203
// sync fireEvent methods with await operator are not valid
195-
...FIRE_EVENT_FUNCTIONS.map(
196-
(func) =>
197-
({
198-
code: `
199-
import { fireEvent } from '@testing-library/framework';
204+
...SUPPORTED_TESTING_FRAMEWORKS.flatMap((testingFramework) =>
205+
FIRE_EVENT_FUNCTIONS.map(
206+
(func) =>
207+
({
208+
code: `
209+
import { fireEvent } from '@testing-library/${testingFramework}';
200210
test('should report fireEvent.${func} sync event awaited', async() => {
201211
await fireEvent.${func}('foo');
202212
});
203213
`,
204-
errors: [
205-
{
206-
line: 4,
207-
column: 17,
208-
messageId: 'noAwaitSyncEvents',
209-
data: { name: `fireEvent.${func}` },
210-
},
211-
],
212-
} as const)
214+
errors: [
215+
{
216+
line: 4,
217+
column: 17,
218+
messageId: 'noAwaitSyncEvents',
219+
data: { name: `fireEvent.${func}` },
220+
},
221+
],
222+
} as const)
223+
)
213224
),
214225
// sync userEvent sync methods with await operator are not valid
215226
...USER_EVENT_SYNC_FUNCTIONS.map(
@@ -234,25 +245,27 @@ ruleTester.run(RULE_NAME, rule, {
234245

235246
// sync fireEvent methods with await operator are not valid
236247
// when only fire-event set in eventModules
237-
...FIRE_EVENT_FUNCTIONS.map(
238-
(func) =>
239-
({
240-
code: `
241-
import { fireEvent } from '@testing-library/framework';
248+
...SUPPORTED_TESTING_FRAMEWORKS.flatMap((testingFramework) =>
249+
FIRE_EVENT_FUNCTIONS.map(
250+
(func) =>
251+
({
252+
code: `
253+
import { fireEvent } from '@testing-library/${testingFramework}';
242254
test('should report fireEvent.${func} sync event awaited', async() => {
243255
await fireEvent.${func}('foo');
244256
});
245257
`,
246-
options: [{ eventModules: ['fire-event'] }],
247-
errors: [
248-
{
249-
line: 4,
250-
column: 17,
251-
messageId: 'noAwaitSyncEvents',
252-
data: { name: `fireEvent.${func}` },
253-
},
254-
],
255-
} as const)
258+
options: [{ eventModules: ['fire-event'] }],
259+
errors: [
260+
{
261+
line: 4,
262+
column: 17,
263+
messageId: 'noAwaitSyncEvents',
264+
data: { name: `fireEvent.${func}` },
265+
},
266+
],
267+
} as const)
268+
)
256269
),
257270
// sync userEvent sync methods with await operator are not valid
258271
// when only fire-event set in eventModules

tests/lib/rules/no-promise-in-fire-event.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { createRuleTester } from '../test-utils';
44
const ruleTester = createRuleTester();
55

66
const SUPPORTED_TESTING_FRAMEWORKS = [
7-
'@testing-library/foo',
87
'@testing-library/dom',
98
'@testing-library/angular',
109
'@testing-library/react',

tests/lib/rules/no-render-in-setup.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { createRuleTester } from '../test-utils';
55
const ruleTester = createRuleTester();
66

77
const SUPPORTED_TESTING_FRAMEWORKS = [
8-
'@testing-library/foo',
98
'@testing-library/angular',
109
'@testing-library/react',
1110
'@testing-library/vue',

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

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { createRuleTester } from '../test-utils';
1515
const ruleTester = createRuleTester();
1616

1717
const SUPPORTED_TESTING_FRAMEWORKS = [
18-
'@testing-library/foo',
1918
'@testing-library/dom',
2019
'@testing-library/angular',
2120
'@testing-library/react',

0 commit comments

Comments
 (0)