mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 15:37:45 +00:00
[web] Add tests for js/components/ContentView/ShowFullContentButton.jsx
This commit is contained in:
parent
298ac8391e
commit
bff23275c3
@ -0,0 +1,39 @@
|
||||
import React from 'react'
|
||||
import renderer from 'react-test-renderer'
|
||||
import { Provider } from 'react-redux'
|
||||
import ConnectedComponent, { ShowFullContentButton } from '../../../components/ContentView/ShowFullContentButton'
|
||||
import { TStore } from '../../ducks/tutils'
|
||||
|
||||
|
||||
describe('ShowFullContentButton Component', () => {
|
||||
let setShowFullContentFn = jest.fn(),
|
||||
showFullContentButton = renderer.create(
|
||||
<ShowFullContentButton
|
||||
setShowFullContent={setShowFullContentFn}
|
||||
showFullContent={false}
|
||||
visibleLines={10}
|
||||
contentLines={20}
|
||||
/>
|
||||
),
|
||||
tree = showFullContentButton.toJSON()
|
||||
|
||||
it('should render correctly', () => {
|
||||
expect(tree).toMatchSnapshot()
|
||||
})
|
||||
|
||||
it('should handle click', () => {
|
||||
tree.children[0].props.onClick()
|
||||
expect(setShowFullContentFn).toBeCalled()
|
||||
})
|
||||
|
||||
it('should connect to state', () => {
|
||||
let store = TStore(),
|
||||
provider = renderer.create(
|
||||
<Provider store={store}>
|
||||
<ConnectedComponent/>
|
||||
</Provider>
|
||||
),
|
||||
tree = provider.toJSON()
|
||||
expect(tree).toMatchSnapshot()
|
||||
})
|
||||
})
|
@ -0,0 +1,25 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`ShowFullContentButton Component should connect to state 1`] = `null`;
|
||||
|
||||
exports[`ShowFullContentButton Component should render correctly 1`] = `
|
||||
<div>
|
||||
<div
|
||||
className="view-all-content-btn btn-xs btn btn-default"
|
||||
disabled={undefined}
|
||||
onClick={[Function]}
|
||||
title={undefined}
|
||||
>
|
||||
Show full content
|
||||
</div>
|
||||
<span
|
||||
className="pull-right"
|
||||
>
|
||||
|
||||
10
|
||||
/
|
||||
20
|
||||
are visible
|
||||
</span>
|
||||
</div>
|
||||
`;
|
@ -12,7 +12,7 @@ ShowFullContentButton.propTypes = {
|
||||
showFullContent: PropTypes.bool.isRequired
|
||||
}
|
||||
|
||||
function ShowFullContentButton ( {setShowFullContent, showFullContent, visibleLines, contentLines} ){
|
||||
export function ShowFullContentButton ( {setShowFullContent, showFullContent, visibleLines, contentLines} ){
|
||||
|
||||
return (
|
||||
!showFullContent &&
|
||||
|
Loading…
Reference in New Issue
Block a user