|
1 | 1 | // make sure you import mocha-config before @angular/core
|
2 |
| -import {assert} from "./test-config"; |
3 |
| -import {Component, ViewContainerRef} from "@angular/core"; |
4 |
| -import {Page} from "ui/page"; |
5 |
| -import {topmost} from "ui/frame"; |
6 |
| -import {ModalDialogParams, ModalDialogService} from "nativescript-angular/directives/dialogs"; |
| 2 | +import { assert } from "./test-config"; |
| 3 | +import { Component, ViewContainerRef } from "@angular/core"; |
| 4 | +import { Page } from "ui/page"; |
| 5 | +import { topmost } from "ui/frame"; |
| 6 | +import { ModalDialogParams, ModalDialogService } from "nativescript-angular/directives/dialogs"; |
7 | 7 |
|
8 |
| -import {device, platformNames} from "platform"; |
| 8 | +import { device, platformNames } from "platform"; |
9 | 9 |
|
10 |
| -import {ComponentFixture} from "@angular/core/testing"; |
11 |
| -import {nsTestBedRender, nsTestBedAfterEach, nsTestBedBeforeEach} from "nativescript-angular/testing"; |
| 10 | +import { ComponentFixture } from "@angular/core/testing"; |
| 11 | +import { nsTestBedRender, nsTestBedAfterEach, nsTestBedBeforeEach } from "nativescript-angular/testing"; |
| 12 | +import { NSLocationStrategy } from "nativescript-angular/router/ns-location-strategy"; |
| 13 | +import { FrameService } from "nativescript-angular"; |
| 14 | +import { FakeFrameService } from "./ns-location-strategy"; |
12 | 15 | const CLOSE_WAIT = (device.os === platformNames.ios) ? 1000 : 0;
|
13 | 16 |
|
14 | 17 | @Component({
|
@@ -50,7 +53,11 @@ export class SuccessComponent {
|
50 | 53 |
|
51 | 54 | describe("modal-dialog", () => {
|
52 | 55 |
|
53 |
| - beforeEach(nsTestBedBeforeEach([FailComponent, SuccessComponent], [], [], [ModalComponent])); |
| 56 | + beforeEach(nsTestBedBeforeEach( |
| 57 | + [FailComponent, SuccessComponent], |
| 58 | + [{ provide: FrameService, useValue: new FakeFrameService() }, NSLocationStrategy], |
| 59 | + [], |
| 60 | + [ModalComponent])); |
54 | 61 | afterEach(nsTestBedAfterEach());
|
55 | 62 | before((done) => {
|
56 | 63 | // HACK: Wait for the navigations from the test runner app
|
@@ -84,14 +91,14 @@ describe("modal-dialog", () => {
|
84 | 91 | .then((fixture: ComponentFixture<SuccessComponent>) => {
|
85 | 92 | const service = <ModalDialogService>fixture.componentRef.instance.service;
|
86 | 93 | const comp = <SuccessComponent>fixture.componentRef.instance;
|
87 |
| - return service.showModal(ModalComponent, {viewContainerRef: comp.vcRef}); |
| 94 | + return service.showModal(ModalComponent, { viewContainerRef: comp.vcRef }); |
88 | 95 | })
|
89 | 96 | .then((res) => setTimeout(done, CLOSE_WAIT)) // wait for the dialog to close in IOS
|
90 | 97 | .catch((e) => done(e));
|
91 | 98 | });
|
92 | 99 |
|
93 | 100 | it("showModal passes modal params and gets result when resolved", (done) => {
|
94 |
| - const context = {property: "my context"}; |
| 101 | + const context = { property: "my context" }; |
95 | 102 | nsTestBedRender(SuccessComponent)
|
96 | 103 | .then((fixture: ComponentFixture<SuccessComponent>) => {
|
97 | 104 | const service = <ModalDialogService>fixture.componentRef.instance.service;
|
|
0 commit comments