[web] Add tests for js/components/EventLog/EventList.jsx

This commit is contained in:
Matthew Shao 2017-05-29 20:39:10 +08:00
parent ec7d7c995c
commit a1ef0b697d
2 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,22 @@
import React from 'react'
import EventLogList from '../../../components/EventLog/EventList'
import TestUtils from 'react-dom/test-utils'
describe('EventList Component', () => {
let mockEventList = [
{ id: 1, level: 'info', message: 'foo' },
{ id: 2, level: 'error', message: 'bar' }
],
eventLogList = TestUtils.renderIntoDocument(<EventLogList events={mockEventList}/>)
it('should render correctly', () => {
expect(eventLogList.state).toMatchSnapshot()
expect(eventLogList.props).toMatchSnapshot()
})
it('should handle componentWillUnmount', () => {
window.removeEventListener = jest.fn()
eventLogList.componentWillUnmount()
expect(window.removeEventListener).toBeCalledWith('resize', eventLogList.onViewportUpdate)
})
})

View File

@ -0,0 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`EventList Component should render correctly 1`] = `
Object {
"vScroll": Object {
"end": 1,
"paddingBottom": 18,
"paddingTop": 0,
"start": 0,
},
}
`;
exports[`EventList Component should render correctly 2`] = `
Object {
"events": Array [
Object {
"id": 1,
"level": "info",
"message": "foo",
},
Object {
"id": 2,
"level": "error",
"message": "bar",
},
],
"rowHeight": 18,
}
`;