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
|
import reduceConnection from "../../ducks/connection"
import * as ConnectionActions from "../../ducks/connection"
import { ConnectionState } from "../../ducks/connection"
describe('connection reducer', () => {
it('should return initial state', () => {
expect(reduceConnection(undefined, {})).toEqual({
state: ConnectionState.INIT,
message: null,
})
})
it('should handle start fetch', () => {
expect(reduceConnection(undefined, ConnectionActions.startFetching())).toEqual({
state: ConnectionState.FETCHING,
message: undefined,
})
})
it('should handle connection established', () => {
expect(reduceConnection(undefined, ConnectionActions.connectionEstablished())).toEqual({
state: ConnectionState.ESTABLISHED,
message: undefined,
})
})
it('should handle connection error', () => {
expect(reduceConnection(undefined, ConnectionActions.connectionError("no internet"))).toEqual({
state: ConnectionState.ERROR,
message: "no internet",
})
})
it('should handle offline mode', () => {
expect(reduceConnection(undefined, ConnectionActions.setOffline())).toEqual({
state: ConnectionState.OFFLINE,
message: undefined,
})
})
})
|