forked from jamielob/reloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreloader-tests.js
69 lines (48 loc) · 1.52 KB
/
reloader-tests.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
68
// NOTE: I think our Reload._onMigrate messes with test app reloading?
// See "Cannot read property '0' of undefined" in browser console
// after editing the code
//
// In order to get test output to update, you may need to
// click the "refresh" header
import { _ } from 'meteor/underscore';
// http://chaijs.com/api/assert/
import { assert } from 'meteor/practicalmeteor:chai';
// http://sinonjs.org/
import sinon from 'sinon'
describe('refresh', function() {
beforeEach(function() {
Reloader.reload = sinon.spy(); // todo save original and repair if needed later
});
describe('startAndResume', function() {
before(function() {
Reloader.configure({
refresh: 'startAndResume'
})
});
it('reloads on resume when update is available', function() {
Reloader.updateAvailable.set(true);
Reloader._onResume();
assert.isTrue(Reloader.reload.called);
});
it("doesn't reload on resume when update isn't available", function() {
Reloader.updateAvailable.set(false);
Reloader._onResume();
assert.isFalse(Reloader.reload.called);
});
})
describe('start', function() {
before(function() {
Reloader.configure({
refresh: 'start'
})
});
it("doesn't reload on resume when update is available", function() {
Reloader.updateAvailable.set(true);
Reloader._onResume();
assert.isFalse(Reloader.reload.called);
});
});
})
describe('check', function() {
// should call / not call _checkForUpdate
})