Permalink
Browse files

fix(navcontrollerbase): popToRoot should not remove root view

  • Loading branch information...
AndreasGassmann authored and manucorporat committed May 3, 2017
1 parent 7aa07b0 commit 646d736d0767ca87d7c87dc54d6ea3ec164c3787
Showing with 20 additions and 1 deletion.
  1. +1 −1 src/navigation/nav-controller-base.ts
  2. +19 −0 src/navigation/test/nav-controller.spec.ts
@@ -331,7 +331,7 @@ export class NavControllerBase extends Ion implements NavController {
if (ti.removeCount < 0) {
ti.removeCount = (viewsLength - ti.removeStart);
}
ti.leavingRequiresTransition = ((ti.removeStart + ti.removeCount) === viewsLength);
ti.leavingRequiresTransition = (ti.removeCount > 0) && ((ti.removeStart + ti.removeCount) === viewsLength);
}
if (ti.insertViews) {
@@ -622,6 +622,25 @@ describe('NavController', () => {
});
}, 10000);
it('should not pop first view if it\'s the only view', (done: Function) => {
let view1 = mockView(MockView1);
mockViews(nav, [view1]);
nav.popToRoot(null, trnsDone).then(() => {
let hasCompleted = true;
let requiresTransition = false;
expect(trnsDone).toHaveBeenCalledWith(
hasCompleted, requiresTransition, undefined, undefined, undefined
);
expect(nav.length()).toEqual(1);
expect(nav.getByIndex(0).component).toEqual(MockView1);
done();
}).catch((err: Error) => {
fail(err);
done(err);
});
}, 10000);
});
describe('remove', () => {

0 comments on commit 646d736

Please sign in to comment.