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