mirror of
https://github.com/vee1e/mitmproxy.git
synced 2026-09-04 19:57:16 +00:00
[web] Add tests for js/components/EventLog/EventList.jsx
This commit is contained in:
parent
ec7d7c995c
commit
a1ef0b697d
2 changed files with 52 additions and 0 deletions
22
web/src/js/__tests__/components/EventLog/EventListSpec.js
Normal file
22
web/src/js/__tests__/components/EventLog/EventListSpec.js
Normal 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)
|
||||
})
|
||||
})
|
||||
|
|
@ -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,
|
||||
}
|
||||
`;
|
||||
Loading…
Add table
Add a link
Reference in a new issue