-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathTokenActions.spec.js
More file actions
54 lines (44 loc) · 1.26 KB
/
TokenActions.spec.js
File metadata and controls
54 lines (44 loc) · 1.26 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
import TokenActions from '../../src/actions/TokenActions';
import TokenConstants from '../../src/constants/TokenConstants';
import chai, {expect} from 'chai';
import spies from 'chai-spies';
chai.use(spies);
describe('TokenActions', () => {
let dispatchSpy;
let callback;
beforeEach(() => {
dispatchSpy = chai.spy(({callback}) => callback());
callback = () => ({});
TokenActions.setDispatch(dispatchSpy);
});
describe('set action', () => {
it('should dispatch a token set action', () => {
const type = 'sometype';
const token = 'sometoken';
TokenActions.set(type, token, callback);
expect(dispatchSpy).to.have.been.calledOnce;
expect(dispatchSpy).to.have.been.called.with({
type: TokenConstants.TOKEN_SET,
options: {
type,
token,
},
callback,
});
});
});
describe('refresh action', () => {
it('should dispatch a refresh action', () => {
const token = 'sometoken';
TokenActions.refresh(token, callback);
expect(dispatchSpy).to.have.been.calledOnce;
expect(dispatchSpy).to.have.been.called.with({
type: TokenConstants.TOKEN_REFRESH,
options: {
token,
},
callback,
});
});
});
});