Skip to content

Commit a3eca9d

Browse files
committed
test: update tests
1 parent ba69239 commit a3eca9d

File tree

1 file changed

+68
-15
lines changed

1 file changed

+68
-15
lines changed

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

Lines changed: 68 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ const ruleTester = createRuleTester();
1616

1717
const SUPPORTED_TESTING_FRAMEWORKS = [
1818
'@testing-library/dom',
19-
'@testing-library/angular',
20-
'@testing-library/react',
21-
'@testing-library/vue',
22-
'@marko/testing-library',
19+
// '@testing-library/angular',
20+
// '@testing-library/react',
21+
// '@testing-library/vue',
22+
// '@marko/testing-library',
2323
];
2424

2525
ruleTester.run(RULE_NAME, rule, {
@@ -34,6 +34,22 @@ ruleTester.run(RULE_NAME, rule, {
3434
await waitFor(function() {
3535
expect(a).toEqual('a')
3636
})
37+
`,
38+
},
39+
{
40+
code: `
41+
await waitFor(function() {
42+
expect(a).toEqual('a')
43+
expect(b).toEqual('b')
44+
})
45+
`,
46+
},
47+
{
48+
code: `
49+
await waitFor(function() {
50+
expect(a).toEqual('a')
51+
expect('a').toEqual('a')
52+
})
3753
`,
3854
},
3955
{
@@ -115,7 +131,18 @@ ruleTester.run(RULE_NAME, rule, {
115131
code: `
116132
await waitFor(() => {
117133
expect(a).toEqual('a')
118-
expect(b).toEqual('b')
134+
expect(a).toEqual('a')
135+
})
136+
`,
137+
errors: [
138+
{ line: 4, column: 11, messageId: 'noWaitForMultipleAssertion' },
139+
],
140+
},
141+
{
142+
code: `
143+
await waitFor(() => {
144+
expect(screen.getByTestId('a')).toHaveTextContent('a')
145+
expect(screen.getByTestId('a')).toHaveTextContent('a')
119146
})
120147
`,
121148
errors: [
@@ -129,7 +156,7 @@ ruleTester.run(RULE_NAME, rule, {
129156
import { waitFor } from '${testingFramework}'
130157
await waitFor(() => {
131158
expect(a).toEqual('a')
132-
expect(b).toEqual('b')
159+
expect(a).toEqual('a')
133160
})
134161
`,
135162
errors: [
@@ -143,7 +170,7 @@ ruleTester.run(RULE_NAME, rule, {
143170
import { waitFor as renamedWaitFor } from 'test-utils'
144171
await renamedWaitFor(() => {
145172
expect(a).toEqual('a')
146-
expect(b).toEqual('b')
173+
expect(a).toEqual('a')
147174
})
148175
`,
149176
errors: [
@@ -155,7 +182,7 @@ ruleTester.run(RULE_NAME, rule, {
155182
await waitFor(() => {
156183
expect(a).toEqual('a')
157184
console.log('testing-library')
158-
expect(b).toEqual('b')
185+
expect(a).toEqual('a')
159186
})
160187
`,
161188
errors: [
@@ -168,7 +195,7 @@ ruleTester.run(RULE_NAME, rule, {
168195
await waitFor(() => {
169196
expect(a).toEqual('a')
170197
console.log('testing-library')
171-
expect(b).toEqual('b')
198+
expect(a).toEqual('a')
172199
})
173200
})
174201
`,
@@ -181,7 +208,7 @@ ruleTester.run(RULE_NAME, rule, {
181208
await waitFor(async () => {
182209
expect(a).toEqual('a')
183210
await somethingAsync()
184-
expect(b).toEqual('b')
211+
expect(a).toEqual('a')
185212
})
186213
`,
187214
errors: [
@@ -192,9 +219,9 @@ ruleTester.run(RULE_NAME, rule, {
192219
code: `
193220
await waitFor(function() {
194221
expect(a).toEqual('a')
195-
expect(b).toEqual('b')
196-
expect(c).toEqual('c')
197-
expect(d).toEqual('d')
222+
expect(a).toEqual('a')
223+
expect(a).toEqual('a')
224+
expect(a).toEqual('a')
198225
})
199226
`,
200227
errors: [
@@ -207,8 +234,22 @@ ruleTester.run(RULE_NAME, rule, {
207234
code: `
208235
await waitFor(function() {
209236
expect(a).toEqual('a')
210-
console.log('testing-library')
237+
expect(a).toEqual('a')
211238
expect(b).toEqual('b')
239+
expect(b).toEqual('b')
240+
})
241+
`,
242+
errors: [
243+
{ line: 4, column: 11, messageId: 'noWaitForMultipleAssertion' },
244+
{ line: 6, column: 11, messageId: 'noWaitForMultipleAssertion' },
245+
],
246+
},
247+
{
248+
code: `
249+
await waitFor(function() {
250+
expect(a).toEqual('a')
251+
console.log('testing-library')
252+
expect(a).toEqual('a')
212253
})
213254
`,
214255
errors: [
@@ -220,8 +261,20 @@ ruleTester.run(RULE_NAME, rule, {
220261
await waitFor(async function() {
221262
expect(a).toEqual('a')
222263
const el = await somethingAsync()
223-
expect(b).toEqual('b')
264+
expect(a).toEqual('a')
224265
})
266+
`,
267+
errors: [
268+
{ line: 5, column: 11, messageId: 'noWaitForMultipleAssertion' },
269+
],
270+
},
271+
{
272+
code: `
273+
await waitFor(() => {
274+
expect(window.fetch).toHaveBeenCalledTimes(1);
275+
expect(localStorage.setItem).toHaveBeenCalledWith('bar', 'baz');
276+
expect(window.fetch).toHaveBeenCalledWith('/foo');
277+
});
225278
`,
226279
errors: [
227280
{ line: 5, column: 11, messageId: 'noWaitForMultipleAssertion' },

0 commit comments

Comments
 (0)