Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

Commit

Permalink
fix(deep-linking): ensure hasExistingDeepLinkConfig returns true wher…
Browse files Browse the repository at this point in the history
…e there is a config referenced by a variable
  • Loading branch information
danbucholtz committed Oct 10, 2017
1 parent 564bd61 commit 2e40340
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
39 changes: 39 additions & 0 deletions src/deep-linking/util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,45 @@ export class AppModule {}
const result = util.hasExistingDeepLinkConfig(knownPath, knownContent);
expect(result).toEqual(false);
});

it('should return true where there is an existing deep link config associated with a variable', () => {
const knownContent = `
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { IonicApp, IonicModule } from 'ionic-angular';
import { MyApp } from './app.component';
import { HomePageModule } from '../pages/home/home.module';
const deepLinkConfig = {
links: [
{ loadChildren: '../pages/page-one/page-one.module#PageOneModule', name: 'PageOne' },
{ loadChildren: '../pages/page-two/page-two.module#PageTwoModule', name: 'PageTwo' },
{ loadChildren: '../pages/page-three/page-three.module#PageThreeModule', name: 'PageThree' }
]
};
@NgModule({
declarations: [
MyApp,
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp, {}, deepLinkConfig),
HomePageModule,
],
bootstrap: [IonicApp],
providers: []
})
export class AppModule {}
`;

const knownPath = join(process.cwd(), 'idk', 'some', 'fake', 'path');

const result = util.hasExistingDeepLinkConfig(knownPath, knownContent);
expect(result).toEqual(true);
});

});

describe('convertDeepLinkEntryToJsObjectString', () => {
Expand Down
12 changes: 11 additions & 1 deletion src/deep-linking/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,17 @@ export function hasExistingDeepLinkConfig(appNgModuleFilePath: string, appNgModu
}

const deepLinkConfigArg = functionCall.arguments[2];
return deepLinkConfigArg.kind === SyntaxKind.ObjectLiteralExpression;
if (deepLinkConfigArg.kind === SyntaxKind.NullKeyword || deepLinkConfigArg.kind === SyntaxKind.UndefinedKeyword) {
return false;
}

if (deepLinkConfigArg.kind === SyntaxKind.ObjectLiteralExpression) {
return true;
}

if ((deepLinkConfigArg as Identifier).text && (deepLinkConfigArg as Identifier).text.length > 0) {
return true;
}
}

function getIonicModuleForRootCall(decorator: Decorator) {
Expand Down

0 comments on commit 2e40340

Please sign in to comment.