-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathitemlist-test.js
33 lines (22 loc) · 1.19 KB
/
itemlist-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// __tests__/itemlist-test.js
jest.dontMock('../components/itemList.jsx');
var React = require('react/addons');
var ItemList = require('../components/itemList.jsx');
var TestUtils = React.addons.TestUtils;
describe('item list', function () {
it('displays three items with right text content', function () {
var testItems = ['foo', 'bar', 'wut'],
itemList = TestUtils.renderIntoDocument(<ItemList items={ testItems } loading={ false } />),
renderedItems = TestUtils.scryRenderedDOMComponentsWithTag(itemList, 'li'),
itemCount = renderedItems.length;
expect(itemCount).toBe(3);
expect(React.findDOMNode(renderedItems[0]).textContent).toEqual('foo');
expect(React.findDOMNode(renderedItems[1]).textContent).toEqual('bar');
expect(React.findDOMNode(renderedItems[2]).textContent).toEqual('wut');
});
it('displays loading div', function () {
var itemList = TestUtils.renderIntoDocument(<ItemList items={ [] } loading={ true } />),
loadingDiv = TestUtils.findRenderedDOMComponentWithClass(itemList, 'loading-label');
expect(React.findDOMNode(loadingDiv).textContent).toEqual('Loading...');
});
});