Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: usage of correct user event methods
  • Loading branch information
renatoagds committed Jul 27, 2020
commit a5f2b40ce4188fb73776d26eaef3ba5c8f14bbfa
8 changes: 4 additions & 4 deletions docs/rules/no-side-effects-wait-for.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ Example of **incorrect** code for this rule:

// or
await waitFor(() => {
userEvent.keyDown(input, { key: 'ArrowDown' });
userEvent.click(button);
expect(b).toEqual('b');
});

// or
await waitFor(function() {
userEvent.keyDown(input, { key: 'ArrowDown' });
userEvent.click(button);
expect(b).toEqual('b');
});
};
Expand All @@ -50,13 +50,13 @@ Examples of **correct** code for this rule:
});

// or
userEvent.keyDown(input, { key: 'ArrowDown' });
userEvent.click(button);
await waitFor(() => {
expect(b).toEqual('b');
});

// or
userEvent.keyDown(input, { key: 'ArrowDown' });
userEvent.click(button);
await waitFor(function() {
expect(b).toEqual('b');
});
Expand Down
20 changes: 14 additions & 6 deletions tests/lib/rules/no-side-effects-wait-for.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ ruleTester.run(RULE_NAME, rule, {
expect(b).toEqual('b')
})
`
}, {
code: `
import { waitFor } from '@testing-library/react';
userEvent.click(button)
await waitFor(function() {
expect(b).toEqual('b')
})
`
}, {
code: `
import { waitFor } from 'react';
Expand Down Expand Up @@ -160,7 +168,7 @@ ruleTester.run(RULE_NAME, rule, {
code: `
import { waitFor } from '@testing-library/react';
await waitFor(() => {
userEvent.keyDown(input, {key: 'ArrowDown'})
userEvent.click(button)
})
`,
errors: [{ messageId: 'noSideEffectsWaitFor' }]
Expand All @@ -170,7 +178,7 @@ ruleTester.run(RULE_NAME, rule, {
import { waitFor } from '@testing-library/react';
await waitFor(() => {
expect(b).toEqual('b')
userEvent.keyDown(input, {key: 'ArrowDown'})
userEvent.click(button)
})
`,
errors: [{ messageId: 'noSideEffectsWaitFor' }]
Expand All @@ -179,7 +187,7 @@ ruleTester.run(RULE_NAME, rule, {
code: `
import { waitFor } from '@testing-library/react';
await waitFor(() => {
userEvent.keyDown(input, {key: 'ArrowDown'})
userEvent.click(button)
expect(b).toEqual('b')
})
`,
Expand All @@ -189,7 +197,7 @@ ruleTester.run(RULE_NAME, rule, {
code: `
import { waitFor } from '@testing-library/react';
await waitFor(function() {
userEvent.keyDown(input, {key: 'ArrowDown'})
userEvent.click(button)
})
`,
errors: [{ messageId: 'noSideEffectsWaitFor' }]
Expand All @@ -199,7 +207,7 @@ ruleTester.run(RULE_NAME, rule, {
import { waitFor } from '@testing-library/react';
await waitFor(function() {
expect(b).toEqual('b')
userEvent.keyDown(input, {key: 'ArrowDown'})
userEvent.click(button)
})
`,
errors: [{ messageId: 'noSideEffectsWaitFor' }]
Expand All @@ -208,7 +216,7 @@ ruleTester.run(RULE_NAME, rule, {
code: `
import { waitFor } from '@testing-library/react';
await waitFor(function() {
userEvent.keyDown(input, {key: 'ArrowDown'})
userEvent.click(button)
expect(b).toEqual('b')
})
`,
Expand Down