diff options
Diffstat (limited to 'e2e/contents')
-rw-r--r-- | e2e/contents/scroll.test.js | 151 | ||||
-rw-r--r-- | e2e/contents/tab.test.js | 216 | ||||
-rw-r--r-- | e2e/contents/zoom.test.js | 72 |
3 files changed, 439 insertions, 0 deletions
diff --git a/e2e/contents/scroll.test.js b/e2e/contents/scroll.test.js new file mode 100644 index 0000000..070529a --- /dev/null +++ b/e2e/contents/scroll.test.js @@ -0,0 +1,151 @@ +import { expect } from "chai"; +import * as windows from "../ambassador/src/client/windows"; +import * as tabs from "../ambassador/src/client/tabs"; +import * as keys from "../ambassador/src/client/keys"; +import * as scrolls from "../ambassador/src/client/scrolls"; + +const SERVER_URL = "localhost:11111"; + +describe("scroll test", () => { + let targetWindow; + let targetTab; + + before(() => { + return windows.create().then((win) => { + targetWindow = win; + return tabs.create(targetWindow.id, SERVER_URL); + }).then((tab) => { + targetTab = tab; + }); + }); + + after(() => { + return windows.remove(targetWindow.id); + }); + + it('scrolls up by k', () => { + let before + return scrolls.set(targetTab.id, 100, 100).then((scroll) => { + before = scroll; + return keys.press(targetTab.id, 'k'); + }).then(() => { + return scrolls.get(targetTab.id); + }).then((actual) => { + expect(actual.y).to.be.lessThan(before.y); + }); + }); + + it('scrolls down by j', () => { + let before + return scrolls.set(targetTab.id, 100, 100).then((scroll) => { + before = scroll; + return keys.press(targetTab.id, 'j'); + }).then(() => { + return scrolls.get(targetTab.id); + }).then((actual) => { + expect(actual.y).to.be.greaterThan(before.y); + }); + }); + + it('scrolls left by h', () => { + let before + return scrolls.set(targetTab.id, 100, 100).then((scroll) => { + before = scroll; + return keys.press(targetTab.id, 'h'); + }).then(() => { + return scrolls.get(targetTab.id); + }).then((actual) => { + expect(actual.x).to.be.lessThan(before.x); + }); + }); + + it('scrolls top by gg', () => { + return scrolls.set(targetTab.id, 100, 100).then((scroll) => { + return keys.press(targetTab.id, 'g'); + }).then(() => { + return keys.press(targetTab.id, 'g'); + }).then(() => { + return scrolls.get(targetTab.id); + }).then((actual) => { + expect(actual.y).to.be.equals(0); + }); + }); + + it('scrolls bottom by G', () => { + return scrolls.set(targetTab.id, 100, 100).then((scroll) => { + return keys.press(targetTab.id, 'G', { shiftKey: true }); + }).then(() => { + return scrolls.get(targetTab.id); + }).then((actual) => { + expect(actual.y).to.be.equals(actual.yMax); + }); + }); + + it('scrolls bottom by 0', () => { + return scrolls.set(targetTab.id, 100, 100).then((scroll) => { + return keys.press(targetTab.id, '0'); + }).then(() => { + return scrolls.get(targetTab.id); + }).then((actual) => { + expect(actual.x).to.be.equals(0); + }); + }); + + it('scrolls bottom by $', () => { + return scrolls.set(targetTab.id, 100, 100).then((scroll) => { + return keys.press(targetTab.id, '$'); + }).then(() => { + return scrolls.get(targetTab.id); + }).then((actual) => { + expect(actual.x).to.be.equals(actual.xMax); + }); + }); + + it('scrolls bottom by <C-U>', () => { + let before + return scrolls.set(targetTab.id, 5000, 5000).then((scroll) => { + before = scroll; + return keys.press(targetTab.id, 'u', { ctrlKey: true }); + }).then(() => { + return scrolls.get(targetTab.id); + }).then((actual) => { + expect(actual.y).to.closeTo(before.y - before.frameHeight / 2, 1); + }); + }); + + it('scrolls bottom by <C-D>', () => { + let before + return scrolls.set(targetTab.id, 5000, 5000).then((scroll) => { + before = scroll; + return keys.press(targetTab.id, 'd', { ctrlKey: true }); + }).then(() => { + return scrolls.get(targetTab.id); + }).then((actual) => { + expect(actual.y).to.closeTo(before.y + before.frameHeight / 2, 1); + }); + }); + + it('scrolls bottom by <C-B>', () => { + let before + return scrolls.set(targetTab.id, 5000, 5000).then((scroll) => { + before = scroll; + return keys.press(targetTab.id, 'b', { ctrlKey: true }); + }).then(() => { + return scrolls.get(targetTab.id); + }).then((actual) => { + expect(actual.y).to.equals(before.y - before.frameHeight); + }); + }); + + it('scrolls bottom by <C-F>', () => { + let before + return scrolls.set(targetTab.id, 5000, 5000).then((scroll) => { + before = scroll; + return keys.press(targetTab.id, 'f', { ctrlKey: true }); + }).then(() => { + return scrolls.get(targetTab.id); + }).then((actual) => { + expect(actual.y).to.equals(before.y + before.frameHeight); + }); + }); +}); diff --git a/e2e/contents/tab.test.js b/e2e/contents/tab.test.js new file mode 100644 index 0000000..4374907 --- /dev/null +++ b/e2e/contents/tab.test.js @@ -0,0 +1,216 @@ +import { expect } from "chai"; +import * as windows from "../ambassador/src/client/windows"; +import * as tabs from "../ambassador/src/client/tabs"; +import * as keys from "../ambassador/src/client/keys"; + +const SERVER_URL = "localhost:11111/"; + +describe("tab test", () => { + let targetWindow; + + beforeEach(() => { + return windows.create(SERVER_URL).then((win) => { + targetWindow = win; + }); + }); + + afterEach(() => { + return windows.remove(targetWindow.id); + }); + + it('deletes tab by d', () => { + let before; + let targetTab; + return tabs.create(targetWindow.id, SERVER_URL).then((tab) => { + targetTab = tab; + return windows.get(targetWindow.id); + }).then((win) => { + before = win; + return keys.press(targetTab.id, 'd'); + }).then(() => { + return windows.get(targetWindow.id); + }).then((actual) => { + expect(actual.tabs).to.have.lengthOf(before.tabs.length - 1); + }); + }); + + it('duplicates tab by zd', () => { + let before; + let targetTab; + return tabs.create(targetWindow.id, SERVER_URL).then((tab) => { + targetTab = tab; + return windows.get(targetWindow.id) + }).then((win) => {; + before = win; + return keys.press(targetTab.id, 'z'); + }).then(() => { + return keys.press(targetTab.id, 'd'); + }).then(() => { + return windows.get(targetWindow.id); + }).then((actual) => { + expect(actual.tabs).to.have.lengthOf(before.tabs.length + 1); + }); + }) + + it('makes pinned by zp', () => { + let before; + let targetTab; + return tabs.create(targetWindow.id, SERVER_URL).then((tab) => { + targetTab = tab; + return windows.get(targetWindow.id) + }).then((win) => {; + before = win; + return keys.press(targetTab.id, 'z'); + }).then(() => { + return keys.press(targetTab.id, 'p'); + }).then(() => { + return windows.get(targetWindow.id); + }).then((actual) => { + expect(actual.tabs[0].pinned).to.be.true; + }); + }) + + it('selects previous tab by K', () => { + return Promise.resolve().then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#1') + }).then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#2') + }).then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#3'); + }).then(() => { + return tabs.selectAt(targetWindow.id, 2); + }).then((tab) => { + return keys.press(tab.id, 'K', { shiftKey: true }); + }).then(() => { + return windows.get(targetWindow.id); + }).then((win) => { + expect(win.tabs[1].active).to.be.true; + }); + }); + + it('selects previous tab by K rotatory', () => { + return Promise.resolve().then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#1') + }).then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#2') + }).then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#3'); + }).then(() => { + return tabs.selectAt(targetWindow.id, 0); + }).then((tab) => { + return keys.press(tab.id, 'K', { shiftKey: true }); + }).then(() => { + return windows.get(targetWindow.id); + }).then((win) => { + expect(win.tabs[3].active).to.be.true; + }); + }); + + it('selects next tab by J', () => { + return Promise.resolve().then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#1') + }).then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#2') + }).then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#3'); + }).then(() => { + return tabs.selectAt(targetWindow.id, 2); + }).then((tab) => { + return keys.press(tab.id, 'J', { shiftKey: true }); + }).then(() => { + return windows.get(targetWindow.id); + }).then((win) => { + expect(win.tabs[3].active).to.be.true; + }); + }); + + it('selects previous tab by J rotatory', () => { + return Promise.resolve().then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#1') + }).then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#2') + }).then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#3'); + }).then(() => { + return tabs.selectAt(targetWindow.id, 3); + }).then((tab) => { + return keys.press(tab.id, 'J', { shiftKey: true }); + }).then(() => { + return windows.get(targetWindow.id); + }).then((win) => { + expect(win.tabs[0].active).to.be.true; + }); + }); + + it('selects first tab by g0', () => { + return Promise.resolve().then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#1') + }).then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#2') + }).then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#3'); + }).then(() => { + return tabs.selectAt(targetWindow.id, 2); + }).then((tab) => { + return keys.press(tab.id, 'g').then(() => tab); + }).then((tab) => { + return keys.press(tab.id, '0'); + }).then(() => { + return windows.get(targetWindow.id); + }).then((win) => { + expect(win.tabs[0].active).to.be.true; + }); + }); + + it('selects last tab by g$', () => { + return Promise.resolve().then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#1') + }).then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#2') + }).then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#3'); + }).then(() => { + return tabs.selectAt(targetWindow.id, 2); + }).then((tab) => { + return keys.press(tab.id, 'g').then(() => tab); + }).then((tab) => { + return keys.press(tab.id, '$'); + }).then(() => { + return windows.get(targetWindow.id); + }).then((win) => { + expect(win.tabs[3].active).to.be.true; + }); + }); + + it('selects last selected tab by <C-6>', () => { + return Promise.resolve().then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#1') + }).then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#2') + }).then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#3'); + }).then(() => { + return tabs.selectAt(targetWindow.id, 1); + }).then(() => { + return tabs.selectAt(targetWindow.id, 3); + }).then((tab) => { + return keys.press(tab.id, '6', { ctrlKey: true }); + }).then(() => { + return windows.get(targetWindow.id); + }).then((win) => { + expect(win.tabs[1].active).to.be.true; + }); + }); + + it('deletes tab by d', () => { + return Promise.resolve().then(() => { + return tabs.create(targetWindow.id, SERVER_URL + '#1'); + }).then((tab) => { + return keys.press(tab.id, 'd'); + }).then(() => { + return windows.get(targetWindow.id); + }).then((win) => { + expect(win.tabs).to.have.lengthOf(1); + }); + }); +}); diff --git a/e2e/contents/zoom.test.js b/e2e/contents/zoom.test.js new file mode 100644 index 0000000..603e0b6 --- /dev/null +++ b/e2e/contents/zoom.test.js @@ -0,0 +1,72 @@ +import { expect } from "chai"; +import * as windows from "../ambassador/src/client/windows"; +import * as tabs from "../ambassador/src/client/tabs"; +import * as keys from "../ambassador/src/client/keys"; + +const SERVER_URL = "localhost:11111/"; + +describe("zoom test", () => { + let targetWindow; + let targetTab; + + before(() => { + return windows.create(SERVER_URL).then((win) => { + targetWindow = win; + }); + }); + + after(() => { + return windows.remove(targetWindow.id); + }); + + beforeEach(() => { + return tabs.create(targetWindow.id, SERVER_URL).then((tab) => { + targetTab = tab; + }); + }); + + 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 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 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); + }); + }); +}); |