-
Notifications
You must be signed in to change notification settings - Fork 13
/
karma-test-setup.js
44 lines (39 loc) · 1.17 KB
/
karma-test-setup.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
var moduleName = require('source/ui.module').moduleName;
var UpgradeModule = require('@angular/upgrade/static').UpgradeModule;
var core = require('@angular/core');
var testingBrowser = require('@angular/platform-browser-dynamic/testing');
var browser = require('@angular/platform-browser');
var forms = require('@angular/forms');
var utilities = require('typescript-angular-utilities');
var ComponentsModule = require('./source/ui.module').ComponentsModule;
class TestModule { ngDoBootstrap() { } }
core.NgModule({
imports: [
browser.BrowserModule,
forms.ReactiveFormsModule,
utilities.UtilitiesModule,
ComponentsModule,
UpgradeModule,
],
})(TestModule)
function setup() {
beforeEach(function () {
angular.mock.module(moduleName);
});
return new Promise(function (resolve) {
var ng2Injector = null;
angular.module(moduleName)
.factory('$$angularInjector', function () {
return {
get: function (token) {
return ng2Injector.get(token);
},
};
});
testingBrowser.platformBrowserDynamicTesting().bootstrapModule(TestModule).then(function(platformRef) {
ng2Injector = platformRef.injector;
resolve();
});
});
}
module.exports = setup;