@@ -54,8 +54,47 @@ export function getSharedIonicModule() {
54
54
expect ( results [ 2 ] . name ) . toEqual ( 'PageTwo' ) ;
55
55
} ) ;
56
56
} ) ;
57
- /*describe('getDeepLinkData', () => {
58
- it('should convert the paths to absolute paths', () => {
57
+
58
+ describe ( 'getDeepLinkData' , ( ) => {
59
+ it ( 'should return an empty list when no valid deep links are found' , ( ) => {
60
+
61
+ const fileContent = `
62
+ import { NgModule } from '@angular/core';
63
+ import { IonicApp, IonicModule } from 'ionic-angular';
64
+ import { MyApp } from './app.component';
65
+ import { HomePage } from '../pages/home/home';
66
+
67
+ import * as Constants from '../util/constants';
68
+
69
+ @NgModule({
70
+ declarations: [
71
+ MyApp,
72
+ HomePage
73
+ ],
74
+ imports: [
75
+ getSharedIonicModule()
76
+ ],
77
+ bootstrap: [IonicApp],
78
+ entryComponents: [
79
+ MyApp,
80
+ HomePage
81
+ ],
82
+ providers: []
83
+ })
84
+ export class AppModule {}
85
+
86
+ export function getSharedIonicModule() {
87
+ return IonicModule.forRoot(MyApp, {});
88
+ }
89
+ ` ;
90
+
91
+ const srcDir = '/Users/dan/Dev/myApp/src' ;
92
+ const result = util . getDeepLinkData ( join ( srcDir , 'app/app.module.ts' ) , fileContent ) ;
93
+ expect ( result ) . toBeTruthy ( ) ;
94
+ expect ( result . length ) . toEqual ( 0 ) ;
95
+ } ) ;
96
+
97
+ it ( 'should return a hydrated deep link config' , ( ) => {
59
98
60
99
const fileContent = `
61
100
import { NgModule } from '@angular/core';
@@ -85,21 +124,27 @@ export class AppModule {}
85
124
export function getSharedIonicModule() {
86
125
return IonicModule.forRoot(MyApp, {}, {
87
126
links: [
88
- { path : '../pages/home/home.module', namedExport: ' HomePageModule', name: 'Home' },
89
- { path : '../pages/page-one/page-one.module', namedExport: ' PageOneModule', name: 'PageOne' },
90
- { path : '../pages/page-two/page-two.module', namedExport: ' PageTwoModule', name: 'PageTwo' }
127
+ { loadChildren : '../pages/home/home.module# HomePageModule', name: 'Home' },
128
+ { loadChildren : '../pages/page-one/page-one.module# PageOneModule', name: 'PageOne' },
129
+ { loadChildren : '../pages/page-two/page-two.module# PageTwoModule', name: 'PageTwo' }
91
130
]
92
131
});
93
132
}
94
133
` ;
95
134
96
135
const srcDir = '/Users/dan/Dev/myApp/src' ;
97
136
const result = util . getDeepLinkData ( join ( srcDir , 'app/app.module.ts' ) , fileContent ) ;
98
- expect(result).toBeTruthy();
99
- expect(result[0].absolutePath).toEqual(join(srcDir, 'pages/home/home.module.ts'));
100
- expect(result[1].absolutePath).toEqual(join(srcDir, 'page-one/page-one.module.ts'));
101
- expect(result[2].absolutePath).toEqual(join(srcDir, 'page-two/page-two.module.ts'));
137
+ expect ( result [ 0 ] . modulePath ) . toEqual ( '../pages/home/home.module' ) ;
138
+ expect ( result [ 0 ] . name ) . toEqual ( 'Home' ) ;
139
+ expect ( result [ 0 ] . absolutePath ) . toEqual ( '/Users/dan/Dev/myApp/src/pages/home/home.module.ts' ) ;
140
+
141
+ expect ( result [ 1 ] . modulePath ) . toEqual ( '../pages/page-one/page-one.module' ) ;
142
+ expect ( result [ 1 ] . name ) . toEqual ( 'PageOne' ) ;
143
+ expect ( result [ 1 ] . absolutePath ) . toEqual ( '/Users/dan/Dev/myApp/src/pages/page-one/page-one.module.ts' ) ;
144
+
145
+ expect ( result [ 2 ] . modulePath ) . toEqual ( '../pages/page-two/page-two.module' ) ;
146
+ expect ( result [ 2 ] . name ) . toEqual ( 'PageTwo' ) ;
147
+ expect ( result [ 2 ] . absolutePath ) . toEqual ( '/Users/dan/Dev/myApp/src/pages/page-two/page-two.module.ts' ) ;
102
148
} ) ;
103
149
} ) ;
104
- */
105
- } ) ;
150
+ } ) ;
0 commit comments