Skip to content

Commit d5d1cd0

Browse files
committed
wip
1 parent ab240e5 commit d5d1cd0

32 files changed

+478
-459
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"typecheck": "tsc",
3131
"lint": "eslint src --cache",
3232
"validate": "yarn prettier && yarn lint && yarn typecheck && yarn test",
33+
"validate:write": "yarn prettier:write && yarn lint --fix && yarn typecheck && yarn test",
3334
"build:js": "babel src --out-dir build --extensions \".js,.ts,.jsx,.tsx\" --source-maps --ignore \"**/__tests__/**\"",
3435
"build:ts": "tsc --build tsconfig.release.json",
3536
"build": "yarn clean && yarn build:js && yarn build:ts",

src/__tests__/act.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ const Counter = () => {
1616
return <Text onPress={() => setCount(count + 1)}>{text}</Text>;
1717
};
1818

19-
test('render should trigger useEffect', () => {
19+
test('render should trigger useEffect', async () => {
2020
const effectCallback = jest.fn();
21-
render(<UseEffect callback={effectCallback} />);
21+
await render(<UseEffect callback={effectCallback} />);
2222

2323
expect(effectCallback).toHaveBeenCalledTimes(1);
2424
});
2525

26-
test('rerender should trigger useEffect', () => {
26+
test('rerender should trigger useEffect', async () => {
2727
const effectCallback = jest.fn();
28-
render(<UseEffect callback={effectCallback} />);
29-
screen.rerender(<UseEffect callback={effectCallback} />);
28+
await render(<UseEffect callback={effectCallback} />);
29+
await screen.rerenderAsync(<UseEffect callback={effectCallback} />);
3030

3131
expect(effectCallback).toHaveBeenCalledTimes(2);
3232
});
3333

3434
test('fireEvent should trigger useState', async () => {
35-
render(<Counter />);
35+
await render(<Counter />);
3636
const counter = screen.getByText(/Total count/i);
3737

3838
expect(counter.props.children).toEqual('Total count: 0');

src/__tests__/auto-cleanup-skip.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ class Test extends React.Component<{ onUnmount?(): void }> {
2929

3030
// This just verifies that by importing RNTL in pure mode in an environment which supports
3131
// afterEach (like jest) we won't get automatic cleanup between tests.
32-
test('component is mounted, but not umounted before test ends', () => {
32+
test('component is mounted, but not umounted before test ends', async () => {
3333
const fn = jest.fn();
34-
render(<Test onUnmount={fn} />);
34+
await render(<Test onUnmount={fn} />);
3535
expect(fn).not.toHaveBeenCalled();
3636
});
3737

src/__tests__/auto-cleanup.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ afterEach(() => {
2727

2828
// This just verifies that by importing RNTL in an environment which supports afterEach (like jest)
2929
// we'll get automatic cleanup between tests.
30-
test('component is mounted, but not umounted before test ends', () => {
30+
test('component is mounted, but not umounted before test ends', async () => {
3131
const fn = jest.fn();
32-
render(<Test onUnmount={fn} />);
32+
await render(<Test onUnmount={fn} />);
3333
expect(isMounted).toEqual(true);
3434
expect(fn).not.toHaveBeenCalled();
3535
});
@@ -38,14 +38,14 @@ test('component is automatically umounted after first test ends', () => {
3838
expect(isMounted).toEqual(false);
3939
});
4040

41-
test('does not time out with legacy fake timers', () => {
41+
test('does not time out with legacy fake timers', async () => {
4242
jest.useFakeTimers({ legacyFakeTimers: true });
43-
render(<Test />);
43+
await render(<Test />);
4444
expect(isMounted).toEqual(true);
4545
});
4646

47-
test('does not time out with fake timers', () => {
47+
test('does not time out with fake timers', async () => {
4848
jest.useFakeTimers();
49-
render(<Test />);
49+
await render(<Test />);
5050
expect(isMounted).toEqual(true);
5151
});

0 commit comments

Comments
 (0)