Repository navigation
Expand file tree
/
Copy pathrefresher.test.js
More file actions
67 lines (48 loc) · 1.53 KB
/
Copy pathrefresher.test.js
File metadata and controls
67 lines (48 loc) · 1.53 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
65
66
67
import Refresher from '../../lib/models/refresher';
describe('Refresher', function() {
let refresher;
beforeEach(function() {
refresher = new Refresher();
});
afterEach(function() {
refresher.dispose();
});
it('calls the latest retry method registered per key instance when triggered', function() {
const keyOne = Symbol('one');
const keyTwo = Symbol('two');
const one0 = sinon.spy();
const one1 = sinon.spy();
const two0 = sinon.spy();
refresher.setRetryCallback(keyOne, one0);
refresher.setRetryCallback(keyOne, one1);
refresher.setRetryCallback(keyTwo, two0);
refresher.trigger();
assert.isFalse(one0.called);
assert.isTrue(one1.called);
assert.isTrue(two0.called);
});
it('deregisters a retry callback for a key', function() {
const keyOne = Symbol('one');
const keyTwo = Symbol('two');
const one = sinon.spy();
const two = sinon.spy();
refresher.setRetryCallback(keyOne, one);
refresher.setRetryCallback(keyTwo, two);
refresher.deregister(keyOne);
refresher.trigger();
assert.isFalse(one.called);
assert.isTrue(two.called);
});
it('deregisters all retry callbacks on dispose', function() {
const keyOne = Symbol('one');
const keyTwo = Symbol('two');
const one = sinon.spy();
const two = sinon.spy();
refresher.setRetryCallback(keyOne, one);
refresher.setRetryCallback(keyTwo, two);
refresher.dispose();
refresher.trigger();
assert.isFalse(one.called);
assert.isFalse(two.called);
});
});