@@ -54,8 +54,47 @@ export function getSharedIonicModule() {
5454 expect ( results [ 2 ] . name ) . toEqual ( 'PageTwo' ) ;
5555 } ) ;
5656 } ) ;
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' , ( ) => {
5998
6099 const fileContent = `
61100import { NgModule } from '@angular/core';
@@ -85,21 +124,27 @@ export class AppModule {}
85124export function getSharedIonicModule() {
86125 return IonicModule.forRoot(MyApp, {}, {
87126 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' }
91130 ]
92131 });
93132}
94133 ` ;
95134
96135 const srcDir = '/Users/dan/Dev/myApp/src' ;
97136 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' ) ;
102148 } ) ;
103149 } ) ;
104- */
105- } ) ;
150+ } ) ;
0 commit comments