[web] Add tests for js/components/FlowTable/FlowRow.js

This commit is contained in:
Matthew Shao 2017-05-22 21:26:27 +08:00
parent 2222f0b65a
commit ab564ea5fd
2 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,21 @@
import React from 'react'
import renderer from 'react-test-renderer'
import FlowRow from '../../../components/FlowTable/FlowRow'
import { TFlow } from '../../ducks/tutils'
describe('FlowRow Component', () => {
let tFlow = new TFlow(),
selectFn = jest.fn(),
flowRow = renderer.create(<FlowRow flow={tFlow} onSelect={selectFn}/>),
tree = flowRow.toJSON()
it('should render correctly', () => {
expect(tree).toMatchSnapshot()
})
it('should handle click', () => {
tree.props.onClick()
expect(selectFn).toBeCalledWith(tFlow.id)
})
})

View File

@ -0,0 +1,47 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`FlowRow Component should render correctly 1`] = `
<tr
className="has-request has-response"
onClick={[Function]}
>
<td
className="col-tls col-tls-http"
/>
<td
className="col-icon"
>
<div
className="resource-icon resource-icon-plain"
/>
</td>
<td
className="col-path"
>
<i
className="fa fa-fw fa-exclamation pull-right"
/>
http://address:22/path
</td>
<td
className="col-method"
>
GET
</td>
<td
className="col-status"
>
200
</td>
<td
className="col-size"
>
14b
</td>
<td
className="col-time"
>
415381h
</td>
</tr>
`;