Skip to content

Commit 5b43a17

Browse files
committed
test: remove lazy modal load unit test
we'll use e2e test for this functionality instead
1 parent 3f241e8 commit 5b43a17

File tree

1 file changed

+4
-68
lines changed

1 file changed

+4
-68
lines changed

tests/app/tests/modal-dialog.ts

Lines changed: 4 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
// make sure you import mocha-config before @angular/core
22
import { assert } from "./test-config";
3-
import { TestApp, bootstrapTestApp } from "./test-app";
4-
import { Location, LocationStrategy } from "@angular/common";
5-
import { Component, ViewContainerRef, NgModuleFactoryLoader, ModuleWithComponentFactories, ComponentFactory, Compiler, Injector, Optional } from "@angular/core";
6-
import { NoPreloading, PreloadingStrategy, ROUTES, Route, Router, RouterModule, RouterOutletMap, Routes, UrlHandlingStrategy, UrlSerializer, provideRoutes, ɵROUTER_PROVIDERS as ROUTER_PROVIDERS, ɵflatten as flatten } from '@angular/router';
7-
import { BehaviorSubject } from "rxjs/BehaviorSubject";
3+
import { TestApp } from "./test-app";
4+
import { Component, ViewContainerRef } from "@angular/core";
85
import { Page } from "ui/page";
96
import { topmost } from "ui/frame";
107
import { ModalDialogParams, ModalDialogService } from "nativescript-angular/directives/dialogs";
11-
import { NSModuleFactoryLoader } from "nativescript-angular/router";
12-
import { HOOKS_LOG } from "../base.component";
13-
const lazyLoadHooksLog = new BehaviorSubject([]);
14-
const lazyLoadHooksLogProvider = { provide: HOOKS_LOG, useValue: lazyLoadHooksLog };
158

169
import { device, platformNames } from "platform";
1710
const CLOSE_WAIT = (device.os === platformNames.ios) ? 1000 : 0;
@@ -40,41 +33,16 @@ export class FailComponent {
4033
}
4134
}
4235

43-
// TODO: this is done temporarily since the SecondModule is used to lazily load on demand here in the tests
44-
// could create module specificly to test this
45-
export function setupTestingRouter(
46-
urlSerializer: UrlSerializer, outletMap: RouterOutletMap, location: Location,
47-
loader: NgModuleFactoryLoader, compiler: Compiler, injector: Injector, routes: Route[][],
48-
urlHandlingStrategy?: UrlHandlingStrategy) {
49-
const router = new Router(
50-
null !, urlSerializer, outletMap, location, injector, loader, compiler, flatten(routes));
51-
if (urlHandlingStrategy) {
52-
router.urlHandlingStrategy = urlHandlingStrategy;
53-
}
54-
return router;
55-
}
56-
5736
@Component({
5837
selector: "sucess-comp",
59-
providers: [
60-
ModalDialogService,
61-
{
62-
provide: Router, useFactory: setupTestingRouter,
63-
deps: [
64-
UrlSerializer, RouterOutletMap, Location, NgModuleFactoryLoader, Compiler, Injector, ROUTES,
65-
[UrlHandlingStrategy, new Optional()]
66-
]
67-
},
68-
lazyLoadHooksLogProvider,
69-
{ provide: NgModuleFactoryLoader, useClass: NSModuleFactoryLoader }
70-
],
38+
providers: [ModalDialogService],
7139
template: `
7240
<GridLayout margin="20">
7341
<Label text="Modal dialogs"></Label>
7442
</GridLayout>`
7543
})
7644
export class SuccessComponent {
77-
constructor(public service: ModalDialogService, public vcRef: ViewContainerRef, public moduleLoader: NgModuleFactoryLoader) {
45+
constructor(public service: ModalDialogService, public vcRef: ViewContainerRef) {
7846
}
7947
}
8048

@@ -141,36 +109,4 @@ describe("modal-dialog", () => {
141109
setTimeout(done, CLOSE_WAIT); // wait for the dialog to close in IOS
142110
}, err => done(err));
143111
});
144-
145-
it("showModal provides module reference option when opening modal component which comes from lazy loaded module", (done) => {
146-
const context = { property: "I was lazy loaded from another module on demand!" };
147-
let service, comp;
148-
testApp.loadComponent(SuccessComponent)
149-
.then((ref) => {
150-
service = <ModalDialogService>ref.instance.service;
151-
comp = <SuccessComponent>ref.instance;
152-
return (<NSModuleFactoryLoader>comp.moduleLoader).loadAndCompileComponents("./lazy-loaded.module#SecondModule");
153-
}).then((mod: any) => {
154-
const moduleRef = (<ModuleWithComponentFactories<any>>mod).ngModuleFactory.create(comp.vcRef.parentInjector);
155-
// find component factory to ref the correct componentType
156-
let lazyModalCmpFactory: ComponentFactory<any>;
157-
for (let cmp of mod.componentFactories) {
158-
if (cmp.selector === "modal-lazy-comp") { // find by selector
159-
lazyModalCmpFactory = cmp;
160-
break;
161-
}
162-
}
163-
164-
return service.showModal(lazyModalCmpFactory.componentType, {
165-
moduleRef,
166-
viewContainerRef: comp.vcRef,
167-
context: context
168-
});
169-
})
170-
.then((res) => {
171-
assert.strictEqual(res, context);
172-
setTimeout(done, CLOSE_WAIT); // wait for the dialog to close in IOS
173-
}, err => done(err));
174-
175-
});
176112
});

0 commit comments

Comments
 (0)