[web] Minor fix and Coverage ++

This commit is contained in:
Matthew Shao 2017-06-26 09:46:29 +08:00
parent d2fa4d8341
commit 9ff29cdb2b
3 changed files with 8 additions and 7 deletions

View File

@ -11,6 +11,7 @@ describe('ContentView Component', () => {
let store = TStore() let store = TStore()
it('should render correctly', () => { it('should render correctly', () => {
store.getState().ui.flow.contentView = 'Edit'
let tflow = TFlow(), let tflow = TFlow(),
provider = renderer.create( provider = renderer.create(
<Provider store={store}> <Provider store={store}>

View File

@ -3,7 +3,7 @@ jest.mock('../../components/EventLog/EventList')
import React from 'react' import React from 'react'
import renderer from 'react-test-renderer' import renderer from 'react-test-renderer'
import TestUtils from 'react-dom/test-utils' import TestUtils from 'react-dom/test-utils'
import ConnectedComponent, { EventLog } from '../../components/EventLog' import EventLog, { PureEventLog } from '../../components/EventLog'
import { Provider } from 'react-redux' import { Provider } from 'react-redux'
import { TStore } from '../ducks/tutils' import { TStore } from '../ducks/tutils'
@ -14,7 +14,7 @@ describe('EventLog Component', () => {
let store = TStore(), let store = TStore(),
provider = renderer.create( provider = renderer.create(
<Provider store={store}> <Provider store={store}>
<ConnectedComponent/> <EventLog/>
</Provider>), </Provider>),
tree = provider.toJSON() tree = provider.toJSON()
@ -22,14 +22,14 @@ describe('EventLog Component', () => {
expect(tree).toMatchSnapshot() expect(tree).toMatchSnapshot()
}) })
it('should handl toggleFilter', () => { it('should handle toggleFilter', () => {
let debugToggleButton = tree.children[0].children[1].children[0] let debugToggleButton = tree.children[0].children[1].children[0]
debugToggleButton.props.onClick() debugToggleButton.props.onClick()
}) })
provider = TestUtils.renderIntoDocument( provider = TestUtils.renderIntoDocument(
<Provider store={store}><ConnectedComponent/></Provider>) <Provider store={store}><EventLog/></Provider>)
let eventLog = TestUtils.findRenderedComponentWithType(provider, EventLog), let eventLog = TestUtils.findRenderedComponentWithType(provider, PureEventLog),
mockEvent = { preventDefault: jest.fn() } mockEvent = { preventDefault: jest.fn() }
it('should handle DragStart', () => { it('should handle DragStart', () => {

View File

@ -5,7 +5,7 @@ import { toggleFilter, toggleVisibility } from '../ducks/eventLog'
import ToggleButton from './common/ToggleButton' import ToggleButton from './common/ToggleButton'
import EventList from './EventLog/EventList' import EventList from './EventLog/EventList'
export class EventLog extends Component { export class PureEventLog extends Component {
static propTypes = { static propTypes = {
filters: PropTypes.object.isRequired, filters: PropTypes.object.isRequired,
@ -77,4 +77,4 @@ export default connect(
close: toggleVisibility, close: toggleVisibility,
toggleFilter: toggleFilter, toggleFilter: toggleFilter,
} }
)(EventLog) )(PureEventLog)