Skip to content

Commit

Permalink
test: Add snapshot tests for ListItem and ListSection component (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
gawrysiak authored and satya164 committed Apr 18, 2018
1 parent 851d998 commit b548111
Show file tree
Hide file tree
Showing 4 changed files with 1,275 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/components/__tests__/ListItem.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* @flow */

import * as React from 'react';
import renderer from 'react-test-renderer';
import { Text } from 'react-native';
import ListItem from '../ListItem';

it('renders list item with title and description', () => {
const tree = renderer
.create(
<ListItem title="First Item" description="Description for first item" />
)
.toJSON();

expect(tree).toMatchSnapshot();
});

it('renders list item with icon', () => {
const tree = renderer
.create(<ListItem title="First Item" icon="folder" />)
.toJSON();

expect(tree).toMatchSnapshot();
});

it('renders list item with avatar', () => {
const tree = renderer
.create(<ListItem title="First Item" avatar={<Text>GG</Text>} />)
.toJSON();

expect(tree).toMatchSnapshot();
});

it('renders list item with avatar and icon', () => {
const tree = renderer
.create(
<ListItem
title="First Item"
description="Item description"
icon="folder"
avatar={<Text>GG</Text>}
/>
)
.toJSON();

expect(tree).toMatchSnapshot();
});
32 changes: 32 additions & 0 deletions src/components/__tests__/ListSection.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* @flow */

import * as React from 'react';
import renderer from 'react-test-renderer';
import ListSection from '../ListSection';
import ListItem from '../ListItem';

it('renders list section without title', () => {
const tree = renderer
.create(
<ListSection>
<ListItem title="First Item" icon="folder" />
<ListItem title="Second Item" icon="folder" />
</ListSection>
)
.toJSON();

expect(tree).toMatchSnapshot();
});

it('renders list section with title', () => {
const tree = renderer
.create(
<ListSection title="Some title">
<ListItem title="First Item" icon="folder" />
<ListItem title="Second Item" icon="folder" />
</ListSection>
)
.toJSON();

expect(tree).toMatchSnapshot();
});
Loading

0 comments on commit b548111

Please sign in to comment.