Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/__tests__/react-native-animated.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,29 @@ describe('AnimatedView', () => {
jest.useRealTimers();
});

it('should use native driver when useNativeDriver is true', () => {
it('should use native driver when useNativeDriver is true', async () => {
render(
<AnimatedView fadeInDuration={250} useNativeDriver={true}>
Test
</AnimatedView>,
);
expect(screen.root).toHaveStyle({ opacity: 0 });

act(() => jest.advanceTimersByTime(250));
// This stopped working in tests in RN 0.77
// expect(screen.root).toHaveStyle({ opacity: 0 });
// eslint-disable-next-line require-await
await act(async () => jest.advanceTimersByTime(250));
expect(screen.root).toHaveStyle({ opacity: 0 });
});

it('should not use native driver when useNativeDriver is false', () => {
it('should not use native driver when useNativeDriver is false', async () => {
render(
<AnimatedView fadeInDuration={250} useNativeDriver={false}>
Test
</AnimatedView>,
);
expect(screen.root).toHaveStyle({ opacity: 0 });

act(() => jest.advanceTimersByTime(250));
// eslint-disable-next-line require-await
await act(async () => jest.advanceTimersByTime(250));
expect(screen.root).toHaveStyle({ opacity: 1 });
});
});
20 changes: 13 additions & 7 deletions src/__tests__/render-hook-async.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,19 +216,25 @@ test('handles custom hooks with complex logic', async () => {
return { count, increment, decrement, reset };
}

const { result, rerenderAsync } = await renderHookAsync(useCounter, { initialProps: 5 });
const { result } = await renderHookAsync(useCounter, { initialProps: 5 });
expect(result.current.count).toBe(5);

result.current.increment();
await rerenderAsync(5);
// eslint-disable-next-line require-await
await act(async () => {
result.current.increment();
});
expect(result.current.count).toBe(6);

result.current.reset();
await rerenderAsync(5);
// eslint-disable-next-line require-await
await act(async () => {
result.current.reset();
});
expect(result.current.count).toBe(5);

result.current.decrement();
await rerenderAsync(5);
// eslint-disable-next-line require-await
await act(async () => {
result.current.decrement();
});
expect(result.current.count).toBe(4);
});

Expand Down
3 changes: 3 additions & 0 deletions src/user-event/scroll/__tests__/scroll-to-flat-list.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,7 @@ test('scrollTo with contentSize and layoutMeasurement update FlatList content',
expect(screen.getByText('Item 0')).toBeOnTheScreen();
expect(screen.getByText('Item 7')).toBeOnTheScreen();
expect(screen.getByText('Item 15')).toBeOnTheScreen();

// Prevent act warning by unmounting the component
await screen.unmountAsync();
});