This repository was archived by the owner on Sep 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathauthentication.test.js
More file actions
64 lines (53 loc) · 1.54 KB
/
Copy pathauthentication.test.js
File metadata and controls
64 lines (53 loc) · 1.54 KB
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
58
59
60
61
62
63
64
import {
handleLoginError,
handleLoginSuccess,
showSessionWarning,
hideSessionWarning,
} from 'actions/AuthActions'
import authentication from './authentication'
describe('Authentication Reducer', () => {
const defaultState = {
authenticated: false,
token: null,
error: null,
showSessionWarning: false,
}
it('should return the initial state', () => {
expect(authentication(undefined, {})).toEqual(defaultState)
})
it('should handle showing the session warning', () => {
const expectedState = {
...defaultState,
showSessionWarning: true,
}
const action = showSessionWarning()
expect(authentication(defaultState, action)).toEqual(expectedState)
})
it('should handle hiding the session warning', () => {
const expectedState = {
...defaultState,
showSessionWarning: false,
}
const action = hideSessionWarning()
expect(authentication({ ...defaultState, showSessionWarning: true }, action))
.toEqual(expectedState)
})
it('should handle login success', () => {
const expectedState = {
...defaultState,
authenticated: true,
error: null,
}
const action = handleLoginSuccess()
expect(authentication(defaultState, action)).toEqual(expectedState)
})
it('should handle login error', () => {
const expectedState = {
...defaultState,
authenticated: false,
error: 'testError',
}
const action = handleLoginError('testError')
expect(authentication(defaultState, action)).toEqual(expectedState)
})
})