/
intro.test.js
59 lines (51 loc) · 1.42 KB
/
intro.test.js
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
/**
* Sample React Native Snapshot Test
*/
import React from 'react';
import {
ActivityIndicator,
FlatList,
Image,
Text,
TextInput,
} from 'react-native';
import renderer from 'react-test-renderer';
import Intro from '../Intro';
jest.setTimeout(15000);
it('renders correctly', () => {
const tree = renderer.create(<Intro />).toJSON();
expect(tree).toMatchSnapshot();
});
// These serve as integration tests for the jest-react-native preset.
it('renders the ActivityIndicator component', () => {
const tree = renderer
.create(<ActivityIndicator animating={true} size="small" />)
.toJSON();
expect(tree).toMatchSnapshot();
});
it('renders the Image component', done => {
Image.getSize('path.jpg', (width, height) => {
const tree = renderer.create(<Image style={{height, width}} />).toJSON();
expect(tree).toMatchSnapshot();
done();
});
});
it('renders the TextInput component', () => {
const tree = renderer
.create(<TextInput autoCorrect={false} value="apple banana kiwi" />)
.toJSON();
expect(tree).toMatchSnapshot();
});
it('renders the FlatList component', () => {
const tree = renderer
.create(
<FlatList
data={['apple', 'banana', 'kiwi']}
keyExtractor={item => item}
renderItem={({item}) => <Text>{item}</Text>}
/>
)
.toJSON();
expect(tree).toMatchSnapshot();
});