A fork of https://github.com/ueokande/vim-vixen
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
127 lines
3.6 KiB
127 lines
3.6 KiB
5 years ago
|
import express from 'express';
|
||
|
import * as path from 'path';
|
||
|
import * as assert from 'assert';
|
||
|
import * as http from 'http';
|
||
|
|
||
|
import { Builder, Lanthan } from 'lanthan';
|
||
|
import { WebDriver, WebElement, By, Key } from 'selenium-webdriver';
|
||
5 years ago
|
|
||
|
const newApp = () => {
|
||
|
let app = express();
|
||
5 years ago
|
app.get('/', (_req, res) => {
|
||
5 years ago
|
res.send(`<!DOCTYPEhtml>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<title>Hello, world!</title>
|
||
|
</head>
|
||
|
</html">`);
|
||
|
});
|
||
|
return app;
|
||
|
};
|
||
|
|
||
|
|
||
5 years ago
|
describe("console test", () => {
|
||
5 years ago
|
const port = 12321;
|
||
5 years ago
|
let http: http.Server;
|
||
|
let lanthan: Lanthan;
|
||
|
let webdriver: WebDriver;
|
||
|
let body: WebElement;
|
||
5 years ago
|
|
||
|
before(async() => {
|
||
|
http = newApp().listen(port);
|
||
5 years ago
|
lanthan = await Builder
|
||
|
.forBrowser('firefox')
|
||
|
.spyAddon(path.join(__dirname, '..'))
|
||
|
.build();
|
||
|
webdriver = lanthan.getWebDriver();
|
||
5 years ago
|
});
|
||
|
|
||
|
after(async() => {
|
||
5 years ago
|
if (lanthan) {
|
||
|
await lanthan.quit();
|
||
|
}
|
||
|
if (http) {
|
||
|
http.close();
|
||
5 years ago
|
}
|
||
|
});
|
||
|
|
||
|
beforeEach(async() => {
|
||
5 years ago
|
await webdriver.navigate().to(`http://127.0.0.1:${port}`);
|
||
|
body = await webdriver.findElement(By.css('body'));
|
||
5 years ago
|
});
|
||
|
|
||
|
it('open console with :', async() => {
|
||
|
await body.sendKeys(':');
|
||
|
|
||
5 years ago
|
await webdriver.switchTo().frame(0);
|
||
5 years ago
|
|
||
5 years ago
|
let input = await webdriver.findElement(By.css('input'));
|
||
5 years ago
|
assert.equal(await input.isDisplayed(), true);
|
||
|
});
|
||
|
|
||
|
it('open console with open command by o', async() => {
|
||
|
await body.sendKeys('o');
|
||
|
|
||
5 years ago
|
await webdriver.switchTo().frame(0);
|
||
5 years ago
|
let value = await webdriver.executeScript(() => document.querySelector('input')!!.value);
|
||
5 years ago
|
assert.equal(value, 'open ');
|
||
|
});
|
||
|
|
||
|
it('open console with open command and current URL by O', async() => {
|
||
5 years ago
|
await body.sendKeys(Key.SHIFT, 'o');
|
||
5 years ago
|
|
||
5 years ago
|
await webdriver.switchTo().frame(0);
|
||
5 years ago
|
let value = await webdriver.executeScript(() => document.querySelector('input')!!.value);
|
||
5 years ago
|
assert.equal(value, `open http://127.0.0.1:${port}/`);
|
||
|
});
|
||
|
|
||
|
it('open console with tabopen command by t', async() => {
|
||
|
await body.sendKeys('t');
|
||
|
|
||
5 years ago
|
await webdriver.switchTo().frame(0);
|
||
5 years ago
|
let value = await webdriver.executeScript(() => document.querySelector('input')!!.value);
|
||
5 years ago
|
assert.equal(value, 'tabopen ');
|
||
|
});
|
||
|
|
||
|
it('open console with tabopen command and current URL by T', async() => {
|
||
5 years ago
|
await body.sendKeys(Key.SHIFT, 't');
|
||
5 years ago
|
|
||
5 years ago
|
await webdriver.switchTo().frame(0);
|
||
5 years ago
|
let value = await webdriver.executeScript(() => document.querySelector('input')!!.value);
|
||
5 years ago
|
assert.equal(value, `tabopen http://127.0.0.1:${port}/`);
|
||
|
});
|
||
|
|
||
|
it('open console with winopen command by w', async() => {
|
||
|
await body.sendKeys('w');
|
||
|
|
||
5 years ago
|
await webdriver.switchTo().frame(0);
|
||
5 years ago
|
let value = await webdriver.executeScript(() => document.querySelector('input')!!.value);
|
||
5 years ago
|
assert.equal(value, 'winopen ');
|
||
|
});
|
||
|
|
||
|
it('open console with winopen command and current URL by W', async() => {
|
||
5 years ago
|
await body.sendKeys(Key.SHIFT, 'W');
|
||
5 years ago
|
|
||
5 years ago
|
await webdriver.switchTo().frame(0);
|
||
5 years ago
|
let value = await webdriver.executeScript(() => document.querySelector('input')!!.value);
|
||
5 years ago
|
assert.equal(value, `winopen http://127.0.0.1:${port}/`);
|
||
|
});
|
||
|
|
||
|
it('open console with buffer command by b', async() => {
|
||
|
await body.sendKeys('b');
|
||
|
|
||
5 years ago
|
await webdriver.switchTo().frame(0);
|
||
5 years ago
|
let value = await webdriver.executeScript(() => document.querySelector('input')!!.value);
|
||
5 years ago
|
assert.equal(value, `buffer `);
|
||
|
});
|
||
|
|
||
|
it('open console with addbookmark command with title by a', async() => {
|
||
|
await body.sendKeys('a');
|
||
|
|
||
5 years ago
|
await webdriver.switchTo().frame(0);
|
||
5 years ago
|
let value = await webdriver.executeScript(() => document.querySelector('input')!!.value);
|
||
5 years ago
|
assert.equal(value, `addbookmark Hello, world!`);
|
||
|
});
|
||
|
});
|
||
|
|