[web] Add tests for js/components/common/DocsLink.jsx

This commit is contained in:
Matthew Shao 2017-05-11 10:25:45 +08:00
parent ce15501c54
commit 9a7ac14654
3 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,17 @@
import React from 'react'
import renderer from 'react-test-renderer'
import DocsLink from '../../../components/common/DocsLink'
describe('DocsLink Component', () => {
it('should be able to be rendered with children nodes', () => {
let docsLink = renderer.create(<DocsLink children="foo" resource="bar"></DocsLink>),
tree = docsLink.toJSON()
expect(tree).toMatchSnapshot()
})
it('should be able to be rendered without children nodes', () => {
let docsLink = renderer.create(<DocsLink resource="bar"></DocsLink>),
tree = docsLink.toJSON()
expect(tree).toMatchSnapshot()
})
})

View File

@ -0,0 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`DocsLink Component should be able to be rendered with children nodes 1`] = `
<a
href="http://docs.mitmproxy.org/en/stable/bar"
target="_blank"
>
foo
</a>
`;
exports[`DocsLink Component should be able to be rendered without children nodes 1`] = `
<a
href="http://docs.mitmproxy.org/en/stable/bar"
target="_blank"
>
<i
className="fa fa-question-circle"
/>
</a>
`;

View File

@ -1,3 +1,4 @@
import React from "react"
import PropTypes from "prop-types"
DocsLink.propTypes = {