Skip to content

Commit 35bd836

Browse files
committed
test: update tests
1 parent 7e170ba commit 35bd836

File tree

1 file changed

+134
-1
lines changed

1 file changed

+134
-1
lines changed

tests/lib/rules/no-wait-for-multiple-assertions.test.ts

Lines changed: 134 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ ruleTester.run(RULE_NAME, rule, {
137137
errors: [
138138
{ line: 4, column: 11, messageId: 'noWaitForMultipleAssertion' },
139139
],
140+
output: `
141+
await waitFor(() => {
142+
expect(a).toEqual('a')
143+
})
144+
expect(a).toEqual('a')
145+
`,
140146
},
141147
{
142148
code: `
@@ -148,6 +154,12 @@ ruleTester.run(RULE_NAME, rule, {
148154
errors: [
149155
{ line: 4, column: 11, messageId: 'noWaitForMultipleAssertion' },
150156
],
157+
output: `
158+
await waitFor(() => {
159+
expect(screen.getByTestId('a')).toHaveTextContent('a')
160+
})
161+
expect(screen.getByTestId('a')).toHaveTextContent('a')
162+
`,
151163
},
152164
...SUPPORTED_TESTING_FRAMEWORKS.map<RuleInvalidTestCase>(
153165
(testingFramework) => ({
@@ -162,6 +174,13 @@ ruleTester.run(RULE_NAME, rule, {
162174
errors: [
163175
{ line: 5, column: 11, messageId: 'noWaitForMultipleAssertion' },
164176
],
177+
output: `// Aggressive Reporting disabled
178+
import { waitFor } from '${testingFramework}'
179+
await waitFor(() => {
180+
expect(a).toEqual('a')
181+
})
182+
expect(a).toEqual('a')
183+
`,
165184
})
166185
),
167186
{
@@ -176,6 +195,13 @@ ruleTester.run(RULE_NAME, rule, {
176195
errors: [
177196
{ line: 5, column: 11, messageId: 'noWaitForMultipleAssertion' },
178197
],
198+
output: `// Aggressive Reporting disabled
199+
import { waitFor as renamedWaitFor } from 'test-utils'
200+
await renamedWaitFor(() => {
201+
expect(a).toEqual('a')
202+
})
203+
expect(a).toEqual('a')
204+
`,
179205
},
180206
{
181207
code: `
@@ -188,6 +214,13 @@ ruleTester.run(RULE_NAME, rule, {
188214
errors: [
189215
{ line: 5, column: 11, messageId: 'noWaitForMultipleAssertion' },
190216
],
217+
output: `
218+
await waitFor(() => {
219+
expect(a).toEqual('a')
220+
console.log('testing-library')
221+
})
222+
expect(a).toEqual('a')
223+
`,
191224
},
192225
{
193226
code: `
@@ -202,6 +235,15 @@ ruleTester.run(RULE_NAME, rule, {
202235
errors: [
203236
{ line: 6, column: 13, messageId: 'noWaitForMultipleAssertion' },
204237
],
238+
output: `
239+
test('should whatever', async () => {
240+
await waitFor(() => {
241+
expect(a).toEqual('a')
242+
console.log('testing-library')
243+
})
244+
expect(a).toEqual('a')
245+
})
246+
`,
205247
},
206248
{
207249
code: `
@@ -214,6 +256,13 @@ ruleTester.run(RULE_NAME, rule, {
214256
errors: [
215257
{ line: 5, column: 11, messageId: 'noWaitForMultipleAssertion' },
216258
],
259+
output: `
260+
await waitFor(async () => {
261+
expect(a).toEqual('a')
262+
await somethingAsync()
263+
})
264+
expect(a).toEqual('a')
265+
`,
217266
},
218267
{
219268
code: `
@@ -229,6 +278,32 @@ ruleTester.run(RULE_NAME, rule, {
229278
{ line: 5, column: 11, messageId: 'noWaitForMultipleAssertion' },
230279
{ line: 6, column: 11, messageId: 'noWaitForMultipleAssertion' },
231280
],
281+
output: [
282+
`
283+
await waitFor(function() {
284+
expect(a).toEqual('a')
285+
expect(a).toEqual('a')
286+
expect(a).toEqual('a')
287+
})
288+
expect(a).toEqual('a')
289+
`,
290+
`
291+
await waitFor(function() {
292+
expect(a).toEqual('a')
293+
expect(a).toEqual('a')
294+
})
295+
expect(a).toEqual('a')
296+
expect(a).toEqual('a')
297+
`,
298+
`
299+
await waitFor(function() {
300+
expect(a).toEqual('a')
301+
})
302+
expect(a).toEqual('a')
303+
expect(a).toEqual('a')
304+
expect(a).toEqual('a')
305+
`,
306+
],
232307
},
233308
{
234309
code: `
@@ -243,6 +318,24 @@ ruleTester.run(RULE_NAME, rule, {
243318
{ line: 4, column: 11, messageId: 'noWaitForMultipleAssertion' },
244319
{ line: 6, column: 11, messageId: 'noWaitForMultipleAssertion' },
245320
],
321+
output: [
322+
`
323+
await waitFor(function() {
324+
expect(a).toEqual('a')
325+
expect(b).toEqual('b')
326+
expect(b).toEqual('b')
327+
})
328+
expect(a).toEqual('a')
329+
`,
330+
`
331+
await waitFor(function() {
332+
expect(a).toEqual('a')
333+
expect(b).toEqual('b')
334+
})
335+
expect(b).toEqual('b')
336+
expect(a).toEqual('a')
337+
`,
338+
],
246339
},
247340
{
248341
code: `
@@ -255,6 +348,13 @@ ruleTester.run(RULE_NAME, rule, {
255348
errors: [
256349
{ line: 5, column: 11, messageId: 'noWaitForMultipleAssertion' },
257350
],
351+
output: `
352+
await waitFor(function() {
353+
expect(a).toEqual('a')
354+
console.log('testing-library')
355+
})
356+
expect(a).toEqual('a')
357+
`,
258358
},
259359
{
260360
code: `
@@ -267,18 +367,51 @@ ruleTester.run(RULE_NAME, rule, {
267367
errors: [
268368
{ line: 5, column: 11, messageId: 'noWaitForMultipleAssertion' },
269369
],
370+
output: `
371+
await waitFor(async function() {
372+
expect(a).toEqual('a')
373+
const el = await somethingAsync()
374+
})
375+
expect(a).toEqual('a')
376+
`,
270377
},
271378
{
272379
code: `
273380
await waitFor(() => {
274381
expect(window.fetch).toHaveBeenCalledTimes(1);
275382
expect(localStorage.setItem).toHaveBeenCalledWith('bar', 'baz');
276383
expect(window.fetch).toHaveBeenCalledWith('/foo');
277-
});
384+
})
385+
`,
386+
errors: [
387+
{ line: 5, column: 11, messageId: 'noWaitForMultipleAssertion' },
388+
],
389+
output: `
390+
await waitFor(() => {
391+
expect(window.fetch).toHaveBeenCalledTimes(1);
392+
expect(localStorage.setItem).toHaveBeenCalledWith('bar', 'baz');
393+
})
394+
expect(window.fetch).toHaveBeenCalledWith('/foo');
395+
`,
396+
},
397+
{
398+
code: `
399+
await waitFor(() => {
400+
expect(window.fetch).toHaveBeenCalledTimes(1);
401+
expect(localStorage.setItem).toHaveBeenCalledWith('bar', 'baz');
402+
expect(window.fetch).toHaveBeenCalledWith('/foo'); // comment
403+
})
278404
`,
279405
errors: [
280406
{ line: 5, column: 11, messageId: 'noWaitForMultipleAssertion' },
281407
],
408+
output: `
409+
await waitFor(() => {
410+
expect(window.fetch).toHaveBeenCalledTimes(1);
411+
expect(localStorage.setItem).toHaveBeenCalledWith('bar', 'baz');
412+
})
413+
expect(window.fetch).toHaveBeenCalledWith('/foo'); // comment
414+
`,
282415
},
283416
],
284417
});

0 commit comments

Comments
 (0)