react-native-fast-image/index.test.js

39 lines
1.0 KiB
JavaScript
Raw Normal View History

2018-02-01 01:27:36 +00:00
import { StyleSheet } from 'react-native'
2017-04-17 23:50:22 +00:00
import React from 'react'
import renderer from 'react-test-renderer'
import FastImage from './index.js'
2017-04-17 23:50:22 +00:00
2018-02-01 01:27:36 +00:00
const style = StyleSheet.create({ image: { width: 44, height: 44 } })
2017-04-17 23:50:22 +00:00
test('FastImage renders correctly.', () => {
2018-05-06 23:04:28 +00:00
const tree = renderer
.create(
<FastImage
source={{
uri: 'https://facebook.github.io/react/img/logo_og.png',
headers: {
token: 'someToken',
},
priority: FastImage.priority.high,
}}
style={style.image}
/>,
)
.toJSON()
2018-02-01 01:27:36 +00:00
2018-05-06 23:04:28 +00:00
expect(tree).toMatchSnapshot()
2018-02-01 01:27:36 +00:00
})
test('Renders a normal Image when not passed a uri.', () => {
2018-05-06 23:04:28 +00:00
const tree = renderer
.create(
<FastImage
source={require('./react-native-fast-image-example-server/pictures/jellyfish.gif')}
style={style.image}
/>,
)
.toJSON()
2017-04-17 23:50:22 +00:00
2018-05-06 23:04:28 +00:00
expect(tree).toMatchSnapshot()
2017-04-17 23:50:22 +00:00
})