Skip to content

Commit

Permalink
Add test for not passing a uri.
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanVann committed Feb 1, 2018
1 parent 864a73e commit 99173cd
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
18 changes: 17 additions & 1 deletion FastImage.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'react-native'
import { StyleSheet } from 'react-native'
import React from 'react'
import renderer from 'react-test-renderer'
import FastImage from './FastImage.js'

const style = StyleSheet.create({ image: { width: 44, height: 44 } })

test('FastImage renders correctly.', () => {
const tree = renderer
.create(
Expand All @@ -14,6 +16,20 @@ test('FastImage renders correctly.', () => {
},
priority: FastImage.priority.high,
}}
style={style.image}
/>,
)
.toJSON()

expect(tree).toMatchSnapshot()
})

test('Renders a normal Image when not passed a uri.', () => {
const tree = renderer
.create(
<FastImage
source={require('./server/pictures/jellyfish.gif')}
style={style.image}
/>,
)
.toJSON()
Expand Down
29 changes: 28 additions & 1 deletion __snapshots__/FastImage.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,33 @@ exports[`FastImage renders correctly. 1`] = `
"uri": "https://facebook.github.io/react/img/logo_og.png",
}
}
style={undefined}
style={
Object {
"height": 44,
"width": 44,
}
}
/>
`;

exports[`Renders a normal Image when not passed a uri. 1`] = `
<Image
onError={undefined}
onLoad={undefined}
onLoadEnd={undefined}
onLoadStart={undefined}
onProgress={undefined}
resizeMode="cover"
source={
Object {
"testUri": "../../../server/pictures/jellyfish.gif",
}
}
style={
Object {
"height": 44,
"width": 44,
}
}
/>
`;

0 comments on commit 99173cd

Please sign in to comment.