Skip to content

Commit 5f86d33

Browse files
committed
test: add tests
1 parent dbbfc4a commit 5f86d33

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/lib/rules/no-unnecessary-act.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,18 @@ const validNonStrictTestCases: RuleValidTestCase[] = [
7878
})
7979
`,
8080
},
81+
{
82+
code: `// case: RTL act wrapping optional chaining call without RTL usage
83+
import { act, render } from '@testing-library/react'
84+
85+
test('valid case', async () => {
86+
act(() => {
87+
render(element);
88+
callback?.();
89+
});
90+
});
91+
`,
92+
},
8193
];
8294

8395
const validTestCases: RuleValidTestCase[] = [
@@ -140,6 +152,19 @@ const validTestCases: RuleValidTestCase[] = [
140152
act(() => stuffThatDoesNotUseRTL()).then(() => {})
141153
act(stuffThatDoesNotUseRTL().then(() => {}))
142154
});
155+
`,
156+
})),
157+
...SUPPORTED_TESTING_FRAMEWORKS.map(([testingFramework, shortName]) => ({
158+
code: `// case: ${shortName} act wrapping non-${shortName} calls
159+
import { act } from '${testingFramework}'
160+
161+
let callback: undefined | (() => void);
162+
163+
test('valid case', async () => {
164+
act(() => {
165+
callback?.();
166+
});
167+
});
143168
`,
144169
})),
145170
{

0 commit comments

Comments
 (0)