-
Notifications
You must be signed in to change notification settings - Fork 8
/
selectors.test.js
67 lines (54 loc) · 1.52 KB
/
selectors.test.js
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
65
66
67
// Copyright 2019 Stanford University see LICENSE for license
import { getCurrentUser, getCurrentSession, getAuthenticationError, getAuthenticationState } from '../src/selectors';
describe('getCurrentUser', () => {
const currentUser = { hello: 'world' }
const state = {
authenticate: {
authenticationState: {
currentUser: currentUser
}
}
};
it('returns user', () => {
expect(getCurrentUser(state)).toBe(currentUser)
})
})
describe('getCurrentSession', () => {
const currentSession = { hello: 'world' }
const state = {
authenticate: {
authenticationState: {
currentSession: currentSession
}
}
};
it('returns currentSession', () => {
expect(getCurrentSession(state)).toBe(currentSession)
})
})
describe('getAuthenticationError', () => {
const authenticationError = { hello: 'world' }
const state = {
authenticate: {
authenticationState: {
authenticationError: authenticationError
}
}
};
it('returns authentication error', () => {
expect(getAuthenticationError(state)).toBe(authenticationError)
})
})
describe('getAuthenticationState', () => {
const authenticationState = { authenticationError: 'broken' }
const state = {
authenticate: {
authenticationState: authenticationState
}
};
it('returns a copy of the authentication state', () => {
const result = getAuthenticationState(state)
expect(result).not.toBe(authenticationState)
expect(result).toEqual(authenticationState)
})
})