Skip to content

Commit

Permalink
fix(navigation): fix swipe-to-go-back
Browse files Browse the repository at this point in the history
fix swipe-to-go-back
  • Loading branch information
danbucholtz committed Jun 30, 2017
1 parent 48b3243 commit 04e78d8
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/navigation/nav-controller-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ export class NavControllerBase extends Ion implements NavController {
canSwipeBack(): boolean {
return (this._sbEnabled &&
!this._isPortal &&
this._child &&
!this._child &&
!this.isTransitioning() &&
this._app.isEnabled() &&
this.canGoBack());
Expand Down
46 changes: 46 additions & 0 deletions src/navigation/test/nav-controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,53 @@ describe('NavController', () => {
});
nav.destroy();
}, 10000);
});

describe('canSwipeBack', () => {
it('should not swipe back when its not enabled', () => {
nav._sbEnabled = false;

const view1 = mockView();
const view2 = mockView();
mockViews(nav, [view1, view2]);

const result = nav.canSwipeBack();
expect(result).toEqual(false);
});

it('should not swipe back if its the portal', () => {
nav._sbEnabled = true;
nav._isPortal = true;

const view1 = mockView();
const view2 = mockView();
mockViews(nav, [view1, view2]);

const result = nav.canSwipeBack();
expect(result).toEqual(false);
});

it('should not swipe back if it has a child nav', () => {
nav._sbEnabled = true;
nav._child = mockNavController();

const view1 = mockView();
const view2 = mockView();
mockViews(nav, [view1, view2]);

const result = nav.canSwipeBack();
expect(result).toEqual(false);
});

it('should swipe back when has a view to go back to', () => {
nav._sbEnabled = true;
const view1 = mockView();
const view2 = mockView();
mockViews(nav, [view1, view2]);

const result = nav.canSwipeBack();
expect(result).toEqual(true);
});
});


Expand Down

0 comments on commit 04e78d8

Please sign in to comment.