Skip to content

Commit efdd7e6

Browse files
Alexander VakrilovSvetoslavTsenov
Alexander Vakrilov
authored andcommitted
fix-next: Add accidentally removed System.import (#7706)
1 parent f3bd2e9 commit efdd7e6

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

tests/app/globals/globals-tests.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import "tns-core-modules/globals";
2+
import * as TKUnit from "../tk-unit";
3+
4+
declare var System: any;
5+
export function test_global_system_import() {
6+
TKUnit.assert(System, "System not defined");
7+
TKUnit.assert(typeof System.import === "function", "System.import not a function");
8+
9+
TKUnit.assert((<any>global).System, "global.System not defined");
10+
TKUnit.assert(typeof (<any>global).System.import === "function", "global.System.import not a function");
11+
}
12+
13+
export function test_global_zonedCallback() {
14+
TKUnit.assert(typeof zonedCallback === "function", "zonedCallback not defined");
15+
TKUnit.assert(typeof global.zonedCallback === "function", "global.zonedCallback not a function");
16+
}
17+
18+
export function test_global_moduleMerge() {
19+
TKUnit.assert(typeof global.moduleMerge === "function", "global.moduleMerge not a function");
20+
}
21+
22+
export function test_global_registerModule() {
23+
TKUnit.assert(typeof global.registerModule === "function", "global.registerModule not a function");
24+
}
25+
26+
export function test_global_registerWebpackModules() {
27+
TKUnit.assert(typeof global.registerWebpackModules === "function", "global.registerWebpackModules not a function");
28+
}
29+
30+
export function test_global_loadModule() {
31+
TKUnit.assert(typeof global.loadModule === "function", "global.loadModule not a function");
32+
}
33+
34+
export function test_global_moduleExists() {
35+
TKUnit.assert(typeof global.moduleExists === "function", "global.moduleExists not a function");
36+
}
37+
38+
export function test_global_getRegisteredModules() {
39+
TKUnit.assert(typeof global.getRegisteredModules === "function", "global.getRegisteredModules not a function");
40+
}
41+
42+
export function test_global_Deprecated() {
43+
TKUnit.assert(typeof global.Deprecated === "function", "global.Deprecated not a function");
44+
}
45+
46+
export function test_global_Experimental() {
47+
TKUnit.assert(typeof global.Experimental === "function", "global.Experimental not a function");
48+
}

tests/app/test-runner.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ export function isRunningOnEmulator(): boolean {
3131

3232
export const allTests = {};
3333

34+
import * as globalsTests from "./globals/globals-tests";
35+
allTests["GLOBALS"] = globalsTests;
36+
3437
import * as domNodeTest from "./debugger/dom-node-tests";
3538
allTests["DOM-NODE"] = domNodeTest;
3639

tns-core-modules/globals/core/globals-core.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,15 @@ global.zonedCallback = function (callback: Function): Function {
2323
return callback;
2424
}
2525
};
26+
27+
(<any>global).System = {
28+
import(path) {
29+
return new Promise((resolve, reject) => {
30+
try {
31+
resolve(global.require(path));
32+
} catch (e) {
33+
reject(e);
34+
}
35+
});
36+
}
37+
};

0 commit comments

Comments
 (0)