Rewrite e2e tests with await/async

jh-changes
Shin'ya Ueoka 7 years ago
parent f1be4fa0a8
commit d6dc869d1f
  1. 78
      e2e/contents/zoom.test.js

@ -7,64 +7,44 @@ describe("zoom test", () => {
let targetWindow; let targetWindow;
let targetTab; let targetTab;
before(() => { before(async () => {
return windows.create(CLIENT_URL).then((win) => { targetWindow = await windows.create(CLIENT_URL);
targetWindow = win;
});
}); });
after(() => { after(async () => {
return windows.remove(targetWindow.id); await windows.remove(targetWindow.id);
}); });
beforeEach(() => { beforeEach(async () => {
return tabs.create(targetWindow.id, CLIENT_URL).then((tab) => { targetTab = await tabs.create(targetWindow.id, CLIENT_URL);
targetTab = tab;
});
}); });
it('zooms-in by zi', () => { it('zooms-in by zi', async () => {
let before; let before = await tabs.getZoom(targetTab.id);
return tabs.getZoom(targetTab.id).then((zoom) => { await keys.press(targetTab.id, 'z');
before = zoom; await keys.press(targetTab.id, 'i');
return keys.press(targetTab.id, 'z');
}).then(() => { let actual = await tabs.getZoom(targetTab.id);
return keys.press(targetTab.id, 'i'); expect(actual).to.be.greaterThan(before);
}).then(() => {
return tabs.getZoom(targetTab.id);
}).then((actual) => {
expect(actual).to.be.greaterThan(before);
});
}); });
it('zooms-in by zo', () => { it('zooms-in by zo', async () => {
let before; let before = await tabs.getZoom(targetTab.id);
return tabs.getZoom(targetTab.id).then((zoom) => { await keys.press(targetTab.id, 'z');
before = zoom; await keys.press(targetTab.id, 'o');
return keys.press(targetTab.id, 'z');
}).then(() => { let actual = await tabs.getZoom(targetTab.id);
return keys.press(targetTab.id, 'o'); expect(actual).to.be.lessThan(before);
}).then(() => {
return tabs.getZoom(targetTab.id);
}).then((actual) => {
expect(actual).to.be.lessThan(before);
});
}); });
it('zooms-in by zz', () => { it('zooms-in by zz', async () => {
let before; await tabs.setZoom(targetTab.id, 1.5);
tabs.setZoom(targetTab.id, 1.5).then(() => { let before = await tabs.getZoom(targetTab.id);
return tabs.getZoom(targetTab.id); await keys.press(targetTab.id, 'z');
}).then((zoom) => { await keys.press(targetTab.id, 'z');
before = zoom;
return keys.press(targetTab.id, 'z'); let actual = await tabs.getZoom(targetTab.id);
}).then(() => { expect(actual).to.be.lessThan(before);
return keys.press(targetTab.id, 'z'); expect(actual).to.equal(1);
}).then(() => {
return tabs.getZoom(targetTab.id);
}).then((actual) => {
expect(actual).to.be.lessThan(before);
expect(actual).to.be.be(1);
});
}); });
}); });