|
1 | 1 | //make sure you import mocha-config before @angular/core
|
2 |
| -import {assert} from "./test-config"; |
3 |
| -import {TestApp} from "./test-app"; |
4 |
| -import {Component, ViewContainerRef} from "@angular/core"; |
5 |
| -import {Page} from "ui/page"; |
6 |
| -import {topmost} from "ui/frame"; |
7 |
| -import {ModalDialogParams, ModalDialogService} from "nativescript-angular/directives/dialogs"; |
8 |
| - |
9 |
| -import {device, platformNames} from "platform"; |
| 2 | +import { assert } from "./test-config"; |
| 3 | +import { TestApp } from "./test-app"; |
| 4 | +import { Component, ViewContainerRef } from "@angular/core"; |
| 5 | +import { Page } from "ui/page"; |
| 6 | +import { topmost } from "ui/frame"; |
| 7 | +import { ModalDialogParams, ModalDialogService } from "nativescript-angular/directives/dialogs"; |
| 8 | + |
| 9 | +import { device, platformNames } from "platform"; |
10 | 10 | const CLOSE_WAIT = (device.os === platformNames.ios) ? 1000 : 0;
|
11 | 11 |
|
12 | 12 | @Component({
|
@@ -37,7 +37,7 @@ export class FailComponent {
|
37 | 37 | selector: "sucess-comp",
|
38 | 38 | providers: [ModalDialogService],
|
39 | 39 | template: `
|
40 |
| - <GridLayout modal-dialog-host margin="20"> |
| 40 | + <GridLayout margin="20"> |
41 | 41 | <Label text="Modal dialogs"></Label>
|
42 | 42 | </GridLayout>`
|
43 | 43 | })
|
@@ -73,39 +73,34 @@ describe('modal-dialog', () => {
|
73 | 73 | });
|
74 | 74 |
|
75 | 75 |
|
76 |
| - it("showModal throws when there is no modal-dialog-host and no viewContainer provided", (done) => { |
| 76 | + it("showModal throws when there is no viewContainer provided", (done) => { |
77 | 77 | testApp.loadComponent(FailComponent)
|
78 | 78 | .then((ref) => {
|
79 | 79 | const service = <ModalDialogService>ref.instance.service;
|
80 | 80 | assert.throws(() => service.showModal(ModalComponent, {}), "No viewContainerRef: Make sure you pass viewContainerRef in ModalDialogOptions.");
|
81 | 81 | }).then(() => done(), err => done(err));
|
82 | 82 | });
|
83 | 83 |
|
84 |
| - it("showModal succeeds when there is modal-dialog-host", (done) => { |
85 |
| - testApp.loadComponent(SuccessComponent) |
86 |
| - .then((ref) => { |
87 |
| - const service = <ModalDialogService>ref.instance.service; |
88 |
| - return service.showModal(ModalComponent, {}); |
89 |
| - }) |
90 |
| - .then((res) => setTimeout(done, CLOSE_WAIT), err => done(err)); // wait for the dialog to close in IOS |
91 |
| - }); |
92 |
| - |
93 | 84 | it("showModal succeeds when there is viewContainer provided", (done) => {
|
94 | 85 | testApp.loadComponent(SuccessComponent)
|
95 | 86 | .then((ref) => {
|
96 | 87 | const service = <ModalDialogService>ref.instance.service;
|
97 |
| - return service.showModal(ModalComponent, {}); |
| 88 | + const comp = <SuccessComponent>ref.instance; |
| 89 | + return service.showModal(ModalComponent, { viewContainerRef: comp.vcRef }); |
98 | 90 | })
|
99 | 91 | .then((res) => setTimeout(done, CLOSE_WAIT), err => done(err)); // wait for the dialog to close in IOS
|
100 | 92 | });
|
101 | 93 |
|
102 |
| - |
103 | 94 | it("showModal passes modal params and gets result when resolved", (done) => {
|
104 | 95 | const context = { property: "my context" };
|
105 | 96 | testApp.loadComponent(SuccessComponent)
|
106 | 97 | .then((ref) => {
|
107 | 98 | const service = <ModalDialogService>ref.instance.service;
|
108 |
| - return service.showModal(ModalComponent, { context: context }); |
| 99 | + const comp = <SuccessComponent>ref.instance; |
| 100 | + return service.showModal(ModalComponent, { |
| 101 | + viewContainerRef: comp.vcRef, |
| 102 | + context: context |
| 103 | + }); |
109 | 104 | })
|
110 | 105 | .then((res) => {
|
111 | 106 | assert.strictEqual(res, context);
|
|
0 commit comments