[Test] Fix port

This commit is contained in:
syuilo 2017-02-08 18:04:33 +09:00
parent 48f9b5070f
commit 5dce30c8ef

View File

@ -20,6 +20,9 @@ process.env.NODE_ENV = 'test';
// Display detail of unhandled promise rejection // Display detail of unhandled promise rejection
process.on('unhandledRejection', console.dir); process.on('unhandledRejection', console.dir);
const port = 3000;
const host = `http://localhost:${port}`;
/* tests below */ /* tests below */
describe('OGP', () => { describe('OGP', () => {
@ -28,8 +31,8 @@ describe('OGP', () => {
app.use((req, res) => { app.use((req, res) => {
res.sendFile(__dirname + '/htmls/og-title.html'); res.sendFile(__dirname + '/htmls/og-title.html');
}); });
const server = app.listen(80, async () => { const server = app.listen(port, async () => {
const summary = await summaly('http://localhost'); const summary = await summaly(host);
assert.equal(summary.title, 'Strawberry Pasta'); assert.equal(summary.title, 'Strawberry Pasta');
server.close(); server.close();
done(); done();
@ -41,8 +44,8 @@ describe('OGP', () => {
app.use((req, res) => { app.use((req, res) => {
res.sendFile(__dirname + '/htmls/og-description.html'); res.sendFile(__dirname + '/htmls/og-description.html');
}); });
const server = app.listen(80, async () => { const server = app.listen(port, async () => {
const summary = await summaly('http://localhost'); const summary = await summaly(host);
assert.equal(summary.description, 'Strawberry Pasta'); assert.equal(summary.description, 'Strawberry Pasta');
server.close(); server.close();
done(); done();
@ -54,8 +57,8 @@ describe('OGP', () => {
app.use((req, res) => { app.use((req, res) => {
res.sendFile(__dirname + '/htmls/og-site_name.html'); res.sendFile(__dirname + '/htmls/og-site_name.html');
}); });
const server = app.listen(80, async () => { const server = app.listen(port, async () => {
const summary = await summaly('http://localhost'); const summary = await summaly(host);
assert.equal(summary.sitename, 'Strawberry Pasta'); assert.equal(summary.sitename, 'Strawberry Pasta');
server.close(); server.close();
done(); done();
@ -67,8 +70,8 @@ describe('OGP', () => {
app.use((req, res) => { app.use((req, res) => {
res.sendFile(__dirname + '/htmls/og-image.html'); res.sendFile(__dirname + '/htmls/og-image.html');
}); });
const server = app.listen(80, async () => { const server = app.listen(port, async () => {
const summary = await summaly('http://localhost'); const summary = await summaly(host);
assert.equal(summary.thumbnail, 'https://himasaku.net/himasaku.png'); assert.equal(summary.thumbnail, 'https://himasaku.net/himasaku.png');
server.close(); server.close();
done(); done();