Skip to content

Commit

Permalink
test(karma): add karma tests for the present/zIndex of a portal
Browse files Browse the repository at this point in the history
references #5426
  • Loading branch information
brandyscarney committed Apr 5, 2016
1 parent 6cd90ee commit 5cb319f
Showing 1 changed file with 59 additions and 1 deletion.
60 changes: 59 additions & 1 deletion ionic/components/nav/test/nav-controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ export function run() {

describe('_setZIndex', () => {

it('should set zIndex off of the previous view to the entering view is loaded and the leavingView is not loaded', () => {
it('should set zIndex off of the previous view to the entering view is loaded and the leavingView is not loaded', () => {
let leavingView = new ViewController();
leavingView.zIndex = 100;
leavingView._loaded = true;
Expand Down Expand Up @@ -638,6 +638,36 @@ export function run() {
expect(enteringView.zIndex).toEqual(0);
});

it('should set zIndex 9999 on first entering portal view', () => {
let enteringView = new ViewController();
enteringView.setPageRef({});
nav._portal = null;
nav._setZIndex(enteringView, null, 'forward');
expect(enteringView.zIndex).toEqual(9999);
});

it('should set zIndex 10000 on second entering portal view', () => {
let leavingView = new ViewController();
leavingView.zIndex = 9999;
leavingView._loaded = true;
let enteringView = new ViewController();
enteringView.setPageRef({});
nav._portal = null;
nav._setZIndex(enteringView, leavingView, 'forward');
expect(enteringView.zIndex).toEqual(10000);
});

it('should set zIndex 9999 on entering portal view going back', () => {
let leavingView = new ViewController();
leavingView.zIndex = 10000;
leavingView._loaded = true;
let enteringView = new ViewController();
enteringView.setPageRef({});
nav._portal = null;
nav._setZIndex(enteringView, leavingView, 'back');
expect(enteringView.zIndex).toEqual(9999);
});

});

describe('_afterTrans', () => {
Expand Down Expand Up @@ -1098,6 +1128,34 @@ export function run() {

});

describe('present', () => {

it('should present in portal', () => {
let enteringView = new ViewController();
enteringView.setPageRef({});
enteringView.usePortal = true;

expect(nav._portal.length()).toBe(0);
expect(nav.length()).toBe(0);
nav.present(enteringView);
expect(nav._portal.length()).toBe(1);
expect(nav.length()).toBe(0);
});

it('should present in main nav', () => {
let enteringView = new ViewController();
enteringView.setPageRef({});
enteringView.usePortal = false;

expect(nav._portal.length()).toBe(0);
expect(nav.length()).toBe(0);
nav.present(enteringView);
expect(nav._portal.length()).toBe(0);
expect(nav.length()).toBe(1);
});

});

it('should getActive()', () => {
expect(nav.getActive()).toBe(null);
let view1 = new ViewController(Page1);
Expand Down

0 comments on commit 5cb319f

Please sign in to comment.