Skip to content

Commit e1d5730

Browse files
committed
basic test
1 parent 4597866 commit e1d5730

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/__tests__/wait-for.test.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import * as React from 'react';
2+
import { Text, View } from 'react-native';
3+
4+
import { render, screen, waitFor } from '..';
5+
6+
test('waits for query', async () => {
7+
function AsyncComponent() {
8+
const [text, setText] = React.useState('Loading...');
9+
10+
React.useEffect(() => {
11+
setTimeout(() => setText('Loaded'), 100);
12+
}, []);
13+
14+
return <Text>{text}</Text>;
15+
}
16+
17+
await render(<AsyncComponent />);
18+
await waitFor(() => screen.getByText('Loaded'));
19+
expect(screen.getByText('Loaded')).toBeOnTheScreen();
20+
});

0 commit comments

Comments
 (0)