-
Notifications
You must be signed in to change notification settings - Fork 37
/
start-app.js
40 lines (34 loc) · 1003 Bytes
/
start-app.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
import Ember from 'ember';
import Application from '../../app';
import config from '../../config/environment';
function ajax(app, url, method, status, response, data, options = {}) {
Ember.run(function() {
Ember.$.fauxjax.removeExisting(url, method);
var request = { url: url , method: method };
if (data) {
request.data = data;
request.contentType = 'application/json';
}
Ember.$.fauxjax.new({
request: request,
response: {
status: status,
content: response,
responseTime: options.responseTime
}
});
});
return app.testHelpers.wait();
}
Ember.Test.registerAsyncHelper('ajax', ajax);
export default function startApp(attrs) {
let application;
// use defaults, but you can override
let attributes = Ember.assign({}, config.APP, attrs);
Ember.run(() => {
application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
});
return application;
}