diff options
Diffstat (limited to 'web/src/js/__tests__/components/FlowView')
-rw-r--r-- | web/src/js/__tests__/components/FlowView/ToggleEditSpec.js | 40 | ||||
-rw-r--r-- | web/src/js/__tests__/components/FlowView/__snapshots__/ToggleEditSpec.js.snap | 17 |
2 files changed, 57 insertions, 0 deletions
diff --git a/web/src/js/__tests__/components/FlowView/ToggleEditSpec.js b/web/src/js/__tests__/components/FlowView/ToggleEditSpec.js new file mode 100644 index 00000000..4578fdc8 --- /dev/null +++ b/web/src/js/__tests__/components/FlowView/ToggleEditSpec.js @@ -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)]) + }) +}) diff --git a/web/src/js/__tests__/components/FlowView/__snapshots__/ToggleEditSpec.js.snap b/web/src/js/__tests__/components/FlowView/__snapshots__/ToggleEditSpec.js.snap new file mode 100644 index 00000000..5a4243a2 --- /dev/null +++ b/web/src/js/__tests__/components/FlowView/__snapshots__/ToggleEditSpec.js.snap @@ -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> +`; |