[web] Add tests for js/components/ContentView/ContentViewOptions.jsx

This commit is contained in:
Matthew Shao 2017-06-01 20:37:38 +08:00
parent de3042911a
commit ef9ee67c19
3 changed files with 65 additions and 1 deletions

View File

@ -0,0 +1,19 @@
import React from 'react'
import renderer from 'react-test-renderer'
import ContentViewOptions from '../../../components/ContentView/ContentViewOptions'
import { Provider } from 'react-redux'
import { TFlow, TStore } from '../../ducks/tutils'
let tflow = new TFlow()
describe('ContentViewOptions Component', () => {
let store = TStore()
it('should render correctly', () => {
let provider = renderer.create(
<Provider store={store}>
<ContentViewOptions flow={tflow} message={tflow.response}/>
</Provider>),
tree = provider.toJSON()
expect(tree).toMatchSnapshot()
})
})

View File

@ -0,0 +1,41 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ContentViewOptions Component should render correctly 1`] = `
<div
className="view-options"
>
<span>
<b>
View:
</b>
edit
</span>
 
<a
className="btn btn-default btn-xs"
href="/flows/d91165be-ca1f-4612-88a9-c0f8696f3e29/response/content"
title="Download the content of the flow."
>
<i
className="fa fa-download"
/>
</a>
 
<a
className="btn btn-default btn-xs"
href="#"
onClick={[Function]}
title="Upload a file to replace the content."
>
<i
className="fa fa-fw fa-upload"
/>
<input
className="hidden"
onChange={[Function]}
type="file"
/>
</a>
 
</div>
`;

View File

@ -4,6 +4,7 @@ import { connect } from 'react-redux'
import ViewSelector from './ViewSelector' import ViewSelector from './ViewSelector'
import UploadContentButton from './UploadContentButton' import UploadContentButton from './UploadContentButton'
import DownloadContentButton from './DownloadContentButton' import DownloadContentButton from './DownloadContentButton'
import { uploadContent } from '../../ducks/flows'
ContentViewOptions.propTypes = { ContentViewOptions.propTypes = {
flow: PropTypes.object.isRequired, flow: PropTypes.object.isRequired,
@ -28,5 +29,8 @@ export default connect(
state => ({ state => ({
contentViewDescription: state.ui.flow.viewDescription, contentViewDescription: state.ui.flow.viewDescription,
readonly: !state.ui.flow.modifiedFlow, readonly: !state.ui.flow.modifiedFlow,
}) }),
{
uploadContent: uploadContent
}
)(ContentViewOptions) )(ContentViewOptions)