@@ -10,6 +10,7 @@ import {Compiler, SystemJsNgModuleLoader} from '@angular/core';
10
10
import { global } from '@angular/core/src/util/global' ;
11
11
import { async } from '@angular/core/testing' ;
12
12
import { afterEach , beforeEach , describe , expect , it } from '@angular/core/testing/src/testing_internal' ;
13
+ import { modifiedInIvy , onlyInIvy } from '@angular/private/testing' ;
13
14
14
15
function mockSystem ( modules : { [ module : string ] : any } ) {
15
16
return {
@@ -20,9 +21,9 @@ function mockSystem(modules: {[module: string]: any}) {
20
21
} ;
21
22
}
22
23
23
- {
24
- describe ( 'SystemJsNgModuleLoader' , ( ) => {
25
- let oldSystem : any = null ;
24
+ describe ( 'SystemJsNgModuleLoader' , ( ) => {
25
+ let oldSystem : any = null ;
26
+ modifiedInIvy ( 'only loads ngfactory shims in View Engine' ) . describe ( '(View Engine)' , ( ) => {
26
27
beforeEach ( ( ) => {
27
28
oldSystem = global [ 'System' ] ;
28
29
global [ 'System' ] = mockSystem ( {
@@ -54,4 +55,26 @@ function mockSystem(modules: {[module: string]: any}) {
54
55
} ) ;
55
56
} ) ) ;
56
57
} ) ;
57
- }
58
+
59
+ onlyInIvy ( 'loads modules directly in Ivy' ) . describe ( '(Ivy)' , ( ) => {
60
+ beforeEach ( ( ) => {
61
+ oldSystem = global [ 'System' ] ;
62
+ global [ 'System' ] = mockSystem ( {
63
+ 'test' : { 'default' : 'test module' , 'NamedModule' : 'test NamedModule' } ,
64
+ } ) ;
65
+ } ) ;
66
+ afterEach ( ( ) => { global [ 'System' ] = oldSystem ; } ) ;
67
+
68
+ it ( 'loads a default module' , async ( ( ) => {
69
+ const loader = new SystemJsNgModuleLoader ( new Compiler ( ) ) ;
70
+ loader . load ( 'test' ) . then (
71
+ contents => { expect ( contents . moduleType ) . toBe ( 'test module' as any ) ; } ) ;
72
+ } ) ) ;
73
+ it ( 'loads a named module' , async ( ( ) => {
74
+ const loader = new SystemJsNgModuleLoader ( new Compiler ( ) ) ;
75
+ loader . load ( 'test#NamedModule' ) . then ( contents => {
76
+ expect ( contents . moduleType ) . toBe ( 'test NamedModule' as any ) ;
77
+ } ) ;
78
+ } ) ) ;
79
+ } ) ;
80
+ } ) ;
0 commit comments