Skip to content
This repository was archived by the owner on Apr 9, 2019. It is now read-only.

Commit a4c5d6a

Browse files
committed
Test lifecycle events by stubbing __transitionViews
1 parent 2c6e462 commit a4c5d6a

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

spec/navigation-controller.spec.jsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,22 +460,30 @@ describe('NavigationController', () => {
460460
})
461461
});
462462
it('calls lifecycle events', (done) => {
463-
const didShowViewSpy = sinon.spy();
463+
const willHideViewSpy = sinon.spy();
464+
const willShowViewSpy = sinon.spy();
464465
const didHideViewSpy = sinon.spy();
465-
controller.__pushView(<ViewB />, {
466-
transition: Transition.type.NONE
467-
});
468-
controller.forceUpdate(() => {
466+
const didShowViewSpy = sinon.spy();
467+
var stub = sinon.stub(controller, '__transitionViews', function (options) {
469468
let prevView = controller.refs['view-0'];
470469
let nextView = controller.refs['view-1'];
470+
prevView.navigationControllerWillHideView = willHideViewSpy;
471+
nextView.navigationControllerWillShowView = willShowViewSpy;
471472
prevView.navigationControllerDidHideView = didHideViewSpy;
472473
nextView.navigationControllerDidShowView = didShowViewSpy;
474+
stub.restore();
475+
controller.__transitionViews(options);
473476
requestAnimationFrame(() => {
477+
expect(willHideViewSpy.calledOnce).to.be.true;
478+
expect(willShowViewSpy.calledOnce).to.be.true;
474479
expect(didHideViewSpy.calledOnce).to.be.true;
475480
expect(didShowViewSpy.calledOnce).to.be.true;
476481
done();
477482
});
478483
});
484+
controller.__pushView(<ViewB />, {
485+
transition: Transition.type.NONE
486+
});
479487
});
480488
});
481489
describe('#__popView', () => {

0 commit comments

Comments
 (0)