-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add snapshot tests for ListItem and ListSection component (#322)
- Loading branch information
Showing
4 changed files
with
1,275 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
Oops, something went wrong.