-
Notifications
You must be signed in to change notification settings - Fork 278
Expand file tree
/
Copy pathAnimatedView.test.tsx
More file actions
39 lines (33 loc) · 1.11 KB
/
AnimatedView.test.tsx
File metadata and controls
39 lines (33 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import * as React from 'react';
import { Text } from 'react-native';
import { act, render, screen } from '@testing-library/react-native';
import { AnimatedView } from '../AnimatedView';
describe('AnimatedView', () => {
beforeEach(() => {
jest.useFakeTimers();
});
afterEach(() => {
jest.useRealTimers();
});
it('should use native driver when useNativeDriver is true', async () => {
await render(
<AnimatedView fadeInDuration={250} useNativeDriver={true}>
<Text>Test</Text>
</AnimatedView>,
);
expect(screen.root).toHaveStyle({ opacity: 0 });
await act(() => jest.advanceTimersByTime(250));
// Does not work with native driver
// expect(screen.root).toHaveStyle({ opacity: 1 });
});
it('should not use native driver when useNativeDriver is false', async () => {
await render(
<AnimatedView fadeInDuration={250} useNativeDriver={false}>
<Text>Test</Text>
</AnimatedView>,
);
expect(screen.root).toHaveStyle({ opacity: 0 });
await act(() => jest.advanceTimersByTime(250));
expect(screen.root).toHaveStyle({ opacity: 1 });
});
});