Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nicolas Goutay
committed
Feb 27, 2016
1 parent
d9a60c9
commit 69707f0
Showing
5 changed files
with
76 additions
and
3 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
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
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
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
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,61 @@ | ||
import React from 'react'; | ||
import TestUtils from 'react-addons-test-utils'; | ||
import TodoList from '../../src/components/TodoList'; | ||
import {expect} from 'chai'; | ||
import {List, Map} from 'immutable'; | ||
|
||
const {renderIntoDocument, | ||
scryRenderedDOMComponentsWithTag} = TestUtils; | ||
|
||
describe('TodoList', () => { | ||
it('renders a list with only the active items if the filter is active', () => { | ||
const todos = List.of( | ||
Map({id: 1, text: 'React', status: 'active'}), | ||
Map({id: 2, text: 'Redux', status: 'active'}), | ||
Map({id: 3, text: 'Immutable', status: 'completed'}) | ||
); | ||
const filter = 'active'; | ||
const component = renderIntoDocument( | ||
<TodoList filter={filter} todos={todos} /> | ||
); | ||
const items = scryRenderedDOMComponentsWithTag(component, 'li'); | ||
|
||
expect(items.length).to.equal(2); | ||
expect(items[0].textContent).to.contain('React'); | ||
expect(items[1].textContent).to.contain('Redux'); | ||
}); | ||
|
||
it('renders a list with only completed items if the filter is completed', () => { | ||
const todos = List.of( | ||
Map({id: 1, text: 'React', status: 'active'}), | ||
Map({id: 2, text: 'Redux', status: 'active'}), | ||
Map({id: 3, text: 'Immutable', status: 'completed'}) | ||
); | ||
const filter = 'completed'; | ||
const component = renderIntoDocument( | ||
<TodoList filter={filter} todos={todos} /> | ||
); | ||
const items = scryRenderedDOMComponentsWithTag(component, 'li'); | ||
|
||
expect(items.length).to.equal(1); | ||
expect(items[0].textContent).to.contain('Immutable'); | ||
}); | ||
|
||
it('renders a list with all the items', () => { | ||
const todos = List.of( | ||
Map({id: 1, text: 'React', status: 'active'}), | ||
Map({id: 2, text: 'Redux', status: 'active'}), | ||
Map({id: 3, text: 'Immutable', status: 'completed'}) | ||
); | ||
const filter = 'all'; | ||
const component = renderIntoDocument( | ||
<TodoList filter={filter} todos={todos} /> | ||
); | ||
const items = scryRenderedDOMComponentsWithTag(component, 'li'); | ||
|
||
expect(items.length).to.equal(3); | ||
expect(items[0].textContent).to.contain('React'); | ||
expect(items[1].textContent).to.contain('Redux'); | ||
expect(items[2].textContent).to.contain('Immutable'); | ||
}); | ||
}); |