Skip to content

Commit

Permalink
Add tests for EntryList component
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-username committed Mar 28, 2018
1 parent b567ff2 commit ae50a55
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/components/EntryList.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import React from 'react';
import EntryList from './EntryList';
import { Text } from 'react-native';
import { ListItem } from 'react-native-elements';

describe('EntryList component', () => {
it('should render as expected', () => {
it('should render CTA if there are no entries yet', () => {
const wrapper = shallow(<EntryList entries={[]} onPress={() => {}} />);
expect(wrapper.find(Text).length).toEqual(2);
expect(wrapper.find(ListItem).length).toEqual(0);
expect(wrapper).toMatchSnapshot();
});

it('should render entries if there are any', () => {
const sampleEntries = [
['md391', { name: 'Bank 1' }],
['krni8', { name: 'Bank 2' }],
Expand All @@ -11,6 +20,7 @@ describe('EntryList component', () => {
const wrapper = shallow(
<EntryList entries={sampleEntries} onPress={() => {}} />
);
expect(wrapper.find(ListItem).length).toEqual(3);
expect(wrapper).toMatchSnapshot();
});
});
40 changes: 39 additions & 1 deletion src/components/__snapshots__/EntryList.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,44 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EntryList component should render as expected 1`] = `
exports[`EntryList component should render CTA if there are no entries yet 1`] = `
<ScrollView>
<View
style={
Object {
"left": 10,
"top": 10,
}
}
>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
style={
Object {
"fontSize": 15,
}
}
>
Hmm, Looks like you have no entries yet.
</Text>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
style={
Object {
"fontSize": 15,
}
}
>
Hit the add button below to get started!
</Text>
</View>
</ScrollView>
`;

exports[`EntryList component should render entries if there are any 1`] = `
<ScrollView>
<List>
<ListItem
Expand Down

0 comments on commit ae50a55

Please sign in to comment.