Skip to content

Commit 8ce373e

Browse files
committed
Merge pull request NativeScript#116 from NativeScript/feature/router-test-fixes
Fix router tests in IOS
2 parents f079305 + 87fa5a9 commit 8ce373e

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

src/nativescript-angular/router/page-router-outlet.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ export class PageRouterOutlet extends RouterOutlet {
188188

189189
this.location.navigateToNewPage();
190190
return new Promise((resolve, reject) => {
191-
page.on('loaded', () => {
192-
// Finish activation when page is fully loaded.
191+
page.on('navigatedTo', () => {
192+
// Finish activation when page is fully navigated to.
193193
resolve(componentRef)
194194
});
195195

tests/app/tests/router.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,14 @@ describe('page-router-outlet', () => {
154154
var initialBackstackLength: number;
155155
var initalPage: Page;
156156

157-
before(() => {
158-
initialBackstackLength = topmost().backStack.length;
159-
initalPage = topmost().currentPage;
157+
before((done) => {
158+
// HACK: Wait for the navigations from the test runner app
159+
// Remove the setTimeout when test runner start tests on page.navigatedTo
160+
setTimeout(() => {
161+
initialBackstackLength = topmost().backStack.length;
162+
initalPage = topmost().currentPage;
163+
done();
164+
}, 1000);
160165
})
161166

162167
beforeEach((done) => {

tests/app/tests/test-app.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ export function bootstrapTestApp(appComponentType: any, providers: ProviderArray
5555
const rootLayout = <LayoutBase>page.content;
5656
const viewRoot = new GridLayout();
5757
rootLayout.addChild(viewRoot);
58-
GridLayout.setRow(rootLayout, 50);
58+
(<any>viewRoot.style).backgroundColor = "white";
59+
viewRoot.margin = "20";
60+
viewRoot.opacity = 0.7;
61+
GridLayout.setRowSpan(rootLayout, 50);
62+
GridLayout.setColumnSpan(rootLayout, 50);
5963

6064
const rootViewProvider = provide(APP_ROOT_VIEW, { useValue: viewRoot });
6165
return bootstrap(appComponentType, providers.concat(rootViewProvider)).then((componentRef) => {

tests/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"id": "org.nativescript.helloworldng",
44
"tns-android": {
55
"version": "1.7.0"
6+
},
7+
"tns-ios": {
8+
"version": "1.7.0"
69
}
710
},
811
"name": "nativescript-hello-world-ng",

0 commit comments

Comments
 (0)