/
test_helper.js
43 lines (33 loc) · 911 Bytes
/
test_helper.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
//= require konacha_config
//= require sinon
//= require application
//= require test_utils
// Sinon fake server
var server;
// Stub out Konacha.reset()
Konacha.reset = Ember.K;
// Prevent automatic scheduling of runloops. For tests, we
// want to have complete control of runloops.
Ember.testing = true;
// Defer App readiness (it will be advanced in each test below)
App.deferReadiness();
// Prevent the router from manipulating the browser's URL.
App.Router.reopen({location: 'none'});
beforeEach(function(done) {
// Fake XHR
server = sinon.fakeServer.create();
Ember.run(function() {
// Advance App readiness, which was deferred above.
App.advanceReadiness();
// Setup is complete when the App readiness promise resolves
App.then(function() {
done();
});
});
});
afterEach(function() {
// Reset App state
App.reset();
// Restore XHR
server.restore();
});