aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/__tests__/components/Header/ConnectionIndicatorSpec.js
blob: 88527d9151cf884a277545553d20a5998da6d312 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import React from 'react'
import renderer from 'react-test-renderer'
import ConnectedIndicator, { ConnectionIndicator } from '../../../components/Header/ConnectionIndicator'
import { ConnectionState } from '../../../ducks/connection'
import { Provider } from 'react-redux'
import configureStore from 'redux-mock-store'

const mockStore = configureStore()

describe('ConnectionIndicator Component', () => {

    it('should render INIT', () => {
        let connectionIndicator = renderer.create(
            <ConnectionIndicator state={ConnectionState.INIT}/>),
            tree = connectionIndicator.toJSON()
        expect(tree).toMatchSnapshot()
    })

    it('should render FETCHING', () => {
        let connectionIndicator = renderer.create(
            <ConnectionIndicator state={ConnectionState.FETCHING}/>),
            tree = connectionIndicator.toJSON()
        expect(tree).toMatchSnapshot()
    })

    it('should render ESTABLISHED', () => {
        let connectionIndicator = renderer.create(
            <ConnectionIndicator state={ConnectionState.ESTABLISHED}/>),
            tree = connectionIndicator.toJSON()
        expect(tree).toMatchSnapshot()
    })

    it('should render ERROR', () => {
        let connectionIndicator = renderer.create(
            <ConnectionIndicator state={ConnectionState.ERROR} message="foo"/>),
            tree = connectionIndicator.toJSON()
        expect(tree).toMatchSnapshot()
    })

    it('should render OFFLINE', () => {
        let connectionIndicator = renderer.create(
            <ConnectionIndicator state={ConnectionState.OFFLINE} />),
            tree = connectionIndicator.toJSON()
        expect(tree).toMatchSnapshot()
    })

    it('should connect to state', () => {
        let store = mockStore({ connection: {state: ConnectionState.INIT} }),
            provider = renderer.create(
            <Provider store={store}>
                <ConnectedIndicator/>
            </Provider>),
        tree = provider.toJSON()
        expect(tree).toMatchSnapshot()
    })
})