aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/__tests__/components/ContentView/ShowFullContentButtonSpec.js
blob: 14871f130489a6bfca57c695fde4b4f9d2e9254a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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()
    })
})