Skip to content

Commit

Permalink
fix RN test
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Aug 27, 2019
1 parent 2e7f8df commit e4d3cb8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
Expand Up @@ -56,7 +56,7 @@ exports[`renders the Image component 1`] = `
/>
`;

exports[`renders the ListView component 1`] = `
exports[`renders the FlatList component 1`] = `
<RCTScrollView
dataSource={
ListViewDataSource {
Expand Down Expand Up @@ -84,6 +84,7 @@ exports[`renders the TextInput component 1`] = `
<TextInput
allowFontScaling={true}
autoCorrect={false}
rejectResponderTermination={true}
underlineColorAndroid="transparent"
value="apple banana kiwi"
/>
Expand Down
30 changes: 12 additions & 18 deletions examples/react-native/__tests__/intro.test.js
Expand Up @@ -4,14 +4,16 @@
* Sample React Native Snapshot Test
*/

'use strict';

import 'react-native';
import React from 'react';
import Intro from '../Intro';

// Note: test renderer must be required after react-native.
import {
ActivityIndicator,
FlatList,
Image,
Text,
TextInput,
} from 'react-native';
import renderer from 'react-test-renderer';
import Intro from '../Intro';

jest.setTimeout(15000);

Expand All @@ -22,15 +24,13 @@ it('renders correctly', () => {

// These serve as integration tests for the jest-react-native preset.
it('renders the ActivityIndicator component', () => {
const ActivityIndicator = require('ActivityIndicator');
const tree = renderer
.create(<ActivityIndicator animating={true} size="small" />)
.toJSON();
expect(tree).toMatchSnapshot();
});

it('renders the Image component', done => {
const Image = require('Image');
Image.getSize('path.jpg', (width, height) => {
const tree = renderer.create(<Image style={{height, width}} />).toJSON();
expect(tree).toMatchSnapshot();
Expand All @@ -39,24 +39,18 @@ it('renders the Image component', done => {
});

it('renders the TextInput component', () => {
const TextInput = require('TextInput');
const tree = renderer
.create(<TextInput autoCorrect={false} value="apple banana kiwi" />)
.toJSON();
expect(tree).toMatchSnapshot();
});

it('renders the ListView component', () => {
const ListView = require('ListView');
const Text = require('Text');
const dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => r1 !== r2,
}).cloneWithRows(['apple', 'banana', 'kiwi']);
it('renders the FlatList component', () => {
const tree = renderer
.create(
<ListView
dataSource={dataSource}
renderRow={rowData => <Text>{rowData}</Text>}
<FlatList
data={['apple', 'banana', 'kiwi']}
renderItem={rowData => <Text>{rowData}</Text>}
/>
)
.toJSON();
Expand Down

0 comments on commit e4d3cb8

Please sign in to comment.