From 7a50301af322667faff8adc1d5990957df9dc4bb Mon Sep 17 00:00:00 2001 From: Matthew Shao Date: Thu, 29 Jun 2017 09:20:11 +0800 Subject: [PATCH] [web] Add tests for js/components/Modal/ModalSpec.js --- .../__tests__/components/Modal/ModalSpec.js | 30 +++++++++ .../Modal/__snapshots__/ModalSpec.js.snap | 62 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 web/src/js/__tests__/components/Modal/ModalSpec.js create mode 100644 web/src/js/__tests__/components/Modal/__snapshots__/ModalSpec.js.snap diff --git a/web/src/js/__tests__/components/Modal/ModalSpec.js b/web/src/js/__tests__/components/Modal/ModalSpec.js new file mode 100644 index 000000000..e4880d084 --- /dev/null +++ b/web/src/js/__tests__/components/Modal/ModalSpec.js @@ -0,0 +1,30 @@ +import React from 'react' +import renderer from 'react-test-renderer' +import Modal from '../../../components/Modal/Modal' +import { Provider } from 'react-redux' +import { TStore } from '../../ducks/tutils' + +describe('Modal Component', () => { + let store = TStore() + + it('should render correctly', () => { + // hide modal by default + let provider = renderer.create( + + + + ), + tree = provider.toJSON() + expect(tree).toMatchSnapshot() + + // option modal show up + store.getState().ui.modal.activeModal = 'OptionModal' + provider = renderer.create( + + + + ) + tree = provider.toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/web/src/js/__tests__/components/Modal/__snapshots__/ModalSpec.js.snap b/web/src/js/__tests__/components/Modal/__snapshots__/ModalSpec.js.snap new file mode 100644 index 000000000..f25c33301 --- /dev/null +++ b/web/src/js/__tests__/components/Modal/__snapshots__/ModalSpec.js.snap @@ -0,0 +1,62 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Modal Component should render correctly 1`] = `
`; + +exports[`Modal Component should render correctly 2`] = ` +
+
+ +`;