aboutsummaryrefslogtreecommitdiff
path: root/e2e/command_bdelete.test.ts
diff options
context:
space:
mode:
authorShin'ya UEOKA <ueokande@i-beam.org>2019-09-27 10:02:12 +0000
committerShin'ya UEOKA <ueokande@i-beam.org>2019-09-29 00:13:04 +0000
commit1b92be636008e9211f460479e246331ba4a1f8f1 (patch)
tree8dbba51444f5f52ad91f0357d2d7035298394452 /e2e/command_bdelete.test.ts
parent4a4b5e13031898440421cef7230c2742e6cd226a (diff)
Use TestServer on e2e
Diffstat (limited to 'e2e/command_bdelete.test.ts')
-rw-r--r--e2e/command_bdelete.test.ts64
1 files changed, 24 insertions, 40 deletions
diff --git a/e2e/command_bdelete.test.ts b/e2e/command_bdelete.test.ts
index 0a9c757..4c76c49 100644
--- a/e2e/command_bdelete.test.ts
+++ b/e2e/command_bdelete.test.ts
@@ -1,46 +1,30 @@
-import express from 'express';
import * as path from 'path';
import * as assert from 'assert';
-import * as http from 'http';
+import TestServer from './lib/TestServer';
import eventually from './eventually';
import { Builder, Lanthan } from 'lanthan';
import { WebDriver } from 'selenium-webdriver';
import Page from './lib/Page';
-const newApp = () => {
- let app = express();
- app.get('/*', (req, res) => {
- res.send(`<!DOCTYPEhtml>
-<html lang="en">
- <head>
- <title>my_${req.path.slice(1)}</title>
- </head>
- <body><h1>${req.path}</h1></body>
-</html">`);
- });
- return app;
-};
-
describe('bdelete/bdeletes command test', () => {
- const port = 12321;
- let http: http.Server;
+ let server = new TestServer().receiveContent('/*', 'ok');
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
before(async() => {
- http = newApp().listen(port);
lanthan = await Builder
.forBrowser('firefox')
.spyAddon(path.join(__dirname, '..'))
.build();
webdriver = lanthan.getWebDriver();
browser = lanthan.getWebExtBrowser();
+ await server.start();
});
after(async() => {
- http.close();
+ await server.stop();
if (lanthan) {
await lanthan.quit();
}
@@ -51,11 +35,11 @@ describe('bdelete/bdeletes command test', () => {
for (let tab of tabs.slice(1)) {
await browser.tabs.remove(tab.id);
}
- await browser.tabs.update(tabs[0].id, { url: `http://127.0.0.1:${port}/site1`, pinned: true });
- await browser.tabs.create({ url: `http://127.0.0.1:${port}/site2`, pinned: true })
- await browser.tabs.create({ url: `http://127.0.0.1:${port}/site3`, pinned: true })
- await browser.tabs.create({ url: `http://127.0.0.1:${port}/site4` })
- await browser.tabs.create({ url: `http://127.0.0.1:${port}/site5` })
+ await browser.tabs.update(tabs[0].id, { url: server.url('/site1'), pinned: true });
+ await browser.tabs.create({ url: server.url('/site2'), pinned: true })
+ await browser.tabs.create({ url: server.url('/site3'), pinned: true })
+ await browser.tabs.create({ url: server.url('/site4'), })
+ await browser.tabs.create({ url: server.url('/site5'), })
await eventually(async() => {
let handles = await webdriver.getAllWindowHandles();
@@ -72,10 +56,10 @@ describe('bdelete/bdeletes command test', () => {
await eventually(async() => {
let tabs = await browser.tabs.query({});
assert.deepEqual(tabs.map((t: any) => t.url), [
- `http://127.0.0.1:${port}/site1`,
- `http://127.0.0.1:${port}/site2`,
- `http://127.0.0.1:${port}/site3`,
- `http://127.0.0.1:${port}/site4`,
+ server.url('/site1'),
+ server.url('/site2'),
+ server.url('/site3'),
+ server.url('/site4'),
])
});
});
@@ -121,10 +105,10 @@ describe('bdelete/bdeletes command test', () => {
await eventually(async() => {
let tabs = await browser.tabs.query({});
assert.deepEqual(tabs.map((t: any) => t.url), [
- `http://127.0.0.1:${port}/site1`,
- `http://127.0.0.1:${port}/site2`,
- `http://127.0.0.1:${port}/site3`,
- `http://127.0.0.1:${port}/site4`,
+ server.url('/site1'),
+ server.url('/site2'),
+ server.url('/site3'),
+ server.url('/site4'),
])
});
});
@@ -137,10 +121,10 @@ describe('bdelete/bdeletes command test', () => {
await eventually(async() => {
let tabs = await browser.tabs.query({});
assert.deepEqual(tabs.map((t: any) => t.url), [
- `http://127.0.0.1:${port}/site2`,
- `http://127.0.0.1:${port}/site3`,
- `http://127.0.0.1:${port}/site4`,
- `http://127.0.0.1:${port}/site5`,
+ server.url('/site2'),
+ server.url('/site3'),
+ server.url('/site4'),
+ server.url('/site5'),
])
});
});
@@ -153,9 +137,9 @@ describe('bdelete/bdeletes command test', () => {
await eventually(async() => {
let tabs = await browser.tabs.query({});
assert.deepEqual(tabs.map((t: any) => t.url), [
- `http://127.0.0.1:${port}/site1`,
- `http://127.0.0.1:${port}/site2`,
- `http://127.0.0.1:${port}/site3`,
+ server.url('/site1'),
+ server.url('/site2'),
+ server.url('/site3'),
])
});
});