fix(test): workaround for nav tests

This commit is contained in:
Manu Mtz.-Almeida
2018-09-05 23:55:26 +02:00
parent 1bcca01e1a
commit a4b11797e4
2 changed files with 11 additions and 7 deletions

View File

@ -888,11 +888,15 @@ describe('NavController', () => {
ionViewWillUnload: jest.spyOn(element, 'ionViewWillUnload'), ionViewWillUnload: jest.spyOn(element, 'ionViewWillUnload'),
}; };
element.addEventListener('ionViewWillEnter', element.ionViewWillEnter); element.dispatchEvent = (ev: CustomEvent) => {
element.addEventListener('ionViewDidEnter', element.ionViewDidEnter); switch(ev.type) {
element.addEventListener('ionViewWillLeave', element.ionViewWillLeave); case 'ionViewWillEnter': element.ionViewWillEnter(); break;
element.addEventListener('ionViewDidLeave', element.ionViewDidLeave); case 'ionViewDidEnter': element.ionViewDidEnter(); break;
element.addEventListener('ionViewWillUnload', element.ionViewWillUnload); case 'ionViewWillLeave': element.ionViewWillLeave(); break;
case 'ionViewDidLeave': element.ionViewDidLeave(); break;
case 'ionViewWillUnload': element.ionViewWillUnload(); break;
}
};
return instance; return instance;
} }

View File

@ -44,7 +44,7 @@ describe('toggle', () => {
}); });
// set unchecked // set unchecked
await toggle.setProperty('checked', false); toggle.setProperty('checked', false);
// wait for the changes to apply // wait for the changes to apply
await page.waitForChanges(); await page.waitForChanges();
@ -97,7 +97,7 @@ describe('toggle', () => {
expect(checkedValue).toBe(true); expect(checkedValue).toBe(true);
// set checked true again, no actual change // set checked true again, no actual change
await toggle.setProperty('checked', true); toggle.setProperty('checked', true);
// wait for the changes to apply // wait for the changes to apply
await page.waitForChanges(); await page.waitForChanges();