mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-25 18:03:50 +00:00
[web] Add tests for js/components/FlowView/ToggleEdit.jsx
This commit is contained in:
parent
f840d018e5
commit
366d0d6280
40
web/src/js/__tests__/components/FlowView/ToggleEditSpec.js
Normal file
40
web/src/js/__tests__/components/FlowView/ToggleEditSpec.js
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// jest.mock('../../../ducks/ui/flow')
|
||||||
|
import React from 'react'
|
||||||
|
import renderer from 'react-test-renderer'
|
||||||
|
import ToggleEdit from '../../../components/FlowView/ToggleEdit'
|
||||||
|
import { Provider } from 'react-redux'
|
||||||
|
import { startEdit, stopEdit } from '../../../ducks/ui/flow'
|
||||||
|
import { TFlow, TStore } from '../../ducks/tutils'
|
||||||
|
|
||||||
|
let tflow = new TFlow()
|
||||||
|
|
||||||
|
describe('ToggleEdit Component', () => {
|
||||||
|
let store = TStore(),
|
||||||
|
provider = renderer.create(
|
||||||
|
<Provider store={store}>
|
||||||
|
<ToggleEdit/>
|
||||||
|
</Provider>),
|
||||||
|
tree = provider.toJSON()
|
||||||
|
|
||||||
|
afterEach(() => { store.clearActions() })
|
||||||
|
|
||||||
|
it('should render correctly', () => {
|
||||||
|
expect(tree).toMatchSnapshot()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should handle click on stopEdit', () => {
|
||||||
|
tree.children[0].props.onClick()
|
||||||
|
expect(store.getActions()).toEqual([stopEdit(tflow, true)])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should handle click on startEdit', () => {
|
||||||
|
store.getState().ui.flow.modifiedFlow = false
|
||||||
|
let provider = renderer.create(
|
||||||
|
<Provider store={store}>
|
||||||
|
<ToggleEdit/>
|
||||||
|
</Provider>),
|
||||||
|
tree = provider.toJSON()
|
||||||
|
tree.children[0].props.onClick()
|
||||||
|
expect(store.getActions()).toEqual([startEdit(tflow)])
|
||||||
|
})
|
||||||
|
})
|
@ -0,0 +1,17 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`ToggleEdit Component should render correctly 1`] = `
|
||||||
|
<div
|
||||||
|
className="edit-flow-container"
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
className="edit-flow"
|
||||||
|
onClick={[Function]}
|
||||||
|
title="Finish Edit"
|
||||||
|
>
|
||||||
|
<i
|
||||||
|
className="fa fa-check"
|
||||||
|
/>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
`;
|
Loading…
Reference in New Issue
Block a user