diff --git a/web/src/js/__tests__/components/EventLog/EventListSpec.js b/web/src/js/__tests__/components/EventLog/EventListSpec.js new file mode 100644 index 000000000..4f14dfba7 --- /dev/null +++ b/web/src/js/__tests__/components/EventLog/EventListSpec.js @@ -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() + + 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) + }) +}) diff --git a/web/src/js/__tests__/components/EventLog/__snapshots__/EventListSpec.js.snap b/web/src/js/__tests__/components/EventLog/__snapshots__/EventListSpec.js.snap new file mode 100644 index 000000000..10bcb5983 --- /dev/null +++ b/web/src/js/__tests__/components/EventLog/__snapshots__/EventListSpec.js.snap @@ -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, +} +`;