Skip to content

Commit df1bfbd

Browse files
ADjenkovADjenkov
ADjenkov
authored and
ADjenkov
committed
chore(unit-tests): modify unit tests to the new location strategy
1 parent 2a3dac4 commit df1bfbd

File tree

9 files changed

+166
-96
lines changed

9 files changed

+166
-96
lines changed

Diff for: e2e/modal-navigation-ng/e2e/modal-frame.e2e-spec.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ describe("modal-frame:", () => {
3333

3434
afterEach(async function () {
3535
if (this.currentTest.state === "failed") {
36-
await driver.logPageSource(this.currentTest.title);
37-
await driver.logScreenshot(this.currentTest.title);
36+
await driver.logTestArtifacts(this.currentTest.title);
3837
await driver.resetApp();
3938
await screen[root]();
4039
}

Diff for: e2e/modal-navigation-ng/e2e/modal-layout.e2e-spec.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ describe("modal-layout:", () => {
3333

3434
afterEach(async function () {
3535
if (this.currentTest.state === "failed") {
36-
await driver.logPageSource(this.currentTest.title);
37-
await driver.logScreenshot(this.currentTest.title);
36+
await driver.logTestArtifacts(this.currentTest.title);
3837
await driver.resetApp();
3938
await screen[root]();
4039
}

Diff for: e2e/modal-navigation-ng/e2e/modal.shared.e2e-spec.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ describe("Shared modal from home and back", () => {
1818

1919
afterEach(async function () {
2020
if (this.currentTest.state === "failed") {
21-
await driver.logPageSource(this.currentTest.title);
22-
await driver.logScreenshot(this.currentTest.title);
21+
await driver.logTestArtifacts(this.currentTest.title);
2322
}
2423
});
2524

Diff for: e2e/nested-router-tab-view/e2e/home-tabs.e2e-spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe("home-tabs:", () => {
3131

3232
afterEach(async function () {
3333
if (this.currentTest.state === "failed") {
34-
await driver.logScreenshot(this.currentTest.title);
34+
await driver.logTestArtifacts(this.currentTest.title);
3535
}
3636
});
3737

Diff for: e2e/nested-router-tab-view/e2e/split-view.e2e-spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe("split-view:", () => {
3131

3232
afterEach(async function () {
3333
if (this.currentTest.state === "failed") {
34-
await driver.logScreenshot(this.currentTest.title);
34+
await driver.logTestArtifacts(this.currentTest.title);
3535
}
3636
});
3737

Diff for: e2e/nested-router-tab-view/e2e/tab-view.e2e-spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("tab-view:", () => {
2626

2727
afterEach(async function () {
2828
if (this.currentTest.state === "failed") {
29-
await driver.logScreenshot(this.currentTest.title);
29+
await driver.logTestArtifacts(this.currentTest.title);
3030
}
3131
});
3232

Diff for: e2e/router-tab-view/e2e/tab-view-navigation.e2e-spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe("TabView with page-router-outlet in each tab", () => {
1515

1616
afterEach(async function () {
1717
if (this.currentTest.state === "failed") {
18-
await driver.logScreenshot(this.currentTest.title);
18+
await driver.logTestArtifacts(this.currentTest.title);
1919
}
2020
});
2121

Diff for: tests/app/tests/modal-dialog.ts

+26-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { device, isIOS } from "tns-core-modules/platform";
99

1010
import { ComponentFixture, async } from "@angular/core/testing";
1111
import { nsTestBedRender, nsTestBedAfterEach, nsTestBedBeforeEach } from "nativescript-angular/testing";
12-
import { NSLocationStrategy } from "nativescript-angular/router/ns-location-strategy";
12+
import { NSLocationStrategy, Outlet } from "nativescript-angular/router/ns-location-strategy";
1313
import { FrameService } from "nativescript-angular";
1414
import { FakeFrameService } from "./ns-location-strategy";
1515
const CLOSE_WAIT = isIOS ? 1000 : 0;
@@ -47,7 +47,11 @@ export class FailComponent {
4747
</GridLayout>`
4848
})
4949
export class SuccessComponent {
50-
constructor(public service: ModalDialogService, public vcRef: ViewContainerRef) {
50+
constructor(
51+
public service: ModalDialogService,
52+
public vcRef: ViewContainerRef,
53+
public locationStrategy: NSLocationStrategy,
54+
public fakeFrameService: FrameService) {
5155
}
5256
}
5357

@@ -88,6 +92,16 @@ describe("modal-dialog", () => {
8892
nsTestBedRender(SuccessComponent)
8993
.then((fixture: ComponentFixture<SuccessComponent>) => {
9094
const service = <ModalDialogService>fixture.componentRef.instance.service;
95+
const locStrategy = <NSLocationStrategy>fixture.componentRef.instance.locationStrategy;
96+
const outlet = new Outlet("primary", "primary", 0);
97+
98+
let parentView = fixture.componentRef.instance.vcRef.element.nativeElement;
99+
parentView = parentView.page && parentView.page.frame;
100+
outlet.frame = parentView;
101+
locStrategy.outlets.push(outlet);
102+
103+
locStrategy.pushState(null, "test", "/test", null);
104+
91105
const comp = <SuccessComponent>fixture.componentRef.instance;
92106
return service.showModal(ModalComponent, { viewContainerRef: comp.vcRef });
93107
})
@@ -100,6 +114,16 @@ describe("modal-dialog", () => {
100114
nsTestBedRender(SuccessComponent)
101115
.then((fixture: ComponentFixture<SuccessComponent>) => {
102116
const service = <ModalDialogService>fixture.componentRef.instance.service;
117+
const locStrategy = <NSLocationStrategy>fixture.componentRef.instance.locationStrategy;
118+
const outlet = new Outlet("primary", "primary", 0);
119+
120+
let parentView = fixture.componentRef.instance.vcRef.element.nativeElement;
121+
parentView = parentView.page && parentView.page.frame;
122+
outlet.frame = parentView;
123+
locStrategy.outlets.push(outlet);
124+
125+
locStrategy.pushState(null, "test", "/test", null);
126+
103127
const comp = <SuccessComponent>fixture.componentRef.instance;
104128
return service.showModal(ModalComponent, {
105129
viewContainerRef: comp.vcRef,

0 commit comments

Comments
 (0)