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

This commit is contained in:
Matthew Shao 2017-06-05 10:19:09 +08:00
parent 46eae0a0b6
commit 298ac8391e
2 changed files with 103 additions and 0 deletions

View File

@ -0,0 +1,37 @@
import React from 'react'
import renderer from 'react-test-renderer'
import { ContentEmpty, ContentMissing, ContentTooLarge } from '../../../components/ContentView/MetaViews'
import { TFlow } from '../../ducks/tutils'
let tflow = new TFlow()
describe('ContentEmpty Components', () => {
it('should render correctly', () => {
let contentEmpty = renderer.create(<ContentEmpty flow={tflow} message={tflow.response}/>),
tree = contentEmpty.toJSON()
expect(tree).toMatchSnapshot()
})
})
describe('ContentMissing Components', () => {
it('should render correctly', () => {
let contentMissing = renderer.create(<ContentMissing flow={tflow} message={tflow.response}/>),
tree = contentMissing.toJSON()
expect(tree).toMatchSnapshot()
})
})
describe('ContentTooLarge Components', () => {
it('should render correctly', () => {
let clickFn = jest.fn(),
uploadContentFn = jest.fn(),
contentTooLarge = renderer.create(<ContentTooLarge
flow={tflow}
message={tflow.response}
onClick={clickFn}
uploadContent={uploadContentFn}
/>),
tree = contentTooLarge.toJSON()
expect(tree).toMatchSnapshot()
})
})

View File

@ -0,0 +1,66 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ContentEmpty Components should render correctly 1`] = `
<div
className="alert alert-info"
>
No
response
content.
</div>
`;
exports[`ContentMissing Components should render correctly 1`] = `
<div
className="alert alert-info"
>
Response
content missing.
</div>
`;
exports[`ContentTooLarge Components should render correctly 1`] = `
<div>
<div
className="alert alert-warning"
>
<button
className="btn btn-xs btn-warning pull-right"
onClick={[Function]}
>
Display anyway
</button>
7b
content size.
</div>
<div
className="view-options text-center"
>
<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>
 
<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>
</div>
</div>
`;