mirror of
https://github.com/misskey-dev/summaly.git
synced 2025-05-09 23:57:20 +09:00
[Test] Add some tests
This commit is contained in:
parent
ac5e6230f6
commit
aa5384ad62
12
test/htmls/no-favicon.html
Normal file
12
test/htmls/no-favicon.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<!doctype html>
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Strawberry Pasta</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Strawberry Pasta</h1>
|
||||||
|
<p>Alice's Strawberry Pasta</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -25,10 +25,37 @@ const host = `http://localhost:${port}`;
|
|||||||
|
|
||||||
/* tests below */
|
/* tests below */
|
||||||
|
|
||||||
|
it('faviconがHTML上で指定されていないが、ルートに存在する場合、正しく設定される', done => {
|
||||||
|
const app = express();
|
||||||
|
app.get('/', (req, res) => {
|
||||||
|
res.sendFile(__dirname + '/htmls/no-favicon.html');
|
||||||
|
});
|
||||||
|
app.get('/favicon.ico', (_, res) => res.sendStatus(200));
|
||||||
|
const server = app.listen(port, async () => {
|
||||||
|
const summary = await summaly(host);
|
||||||
|
assert.equal(summary.icon, `${host}/favicon.ico`);
|
||||||
|
server.close();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('faviconがHTML上で指定されていなくて、ルートにも存在しなかった場合 null になる', done => {
|
||||||
|
const app = express();
|
||||||
|
app.get('/', (req, res) => {
|
||||||
|
res.sendFile(__dirname + '/htmls/no-favicon.html');
|
||||||
|
});
|
||||||
|
const server = app.listen(port, async () => {
|
||||||
|
const summary = await summaly(host);
|
||||||
|
assert.equal(summary.icon, null);
|
||||||
|
server.close();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('OGP', () => {
|
describe('OGP', () => {
|
||||||
it('title', done => {
|
it('title', done => {
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use((req, res) => {
|
app.get('/', (req, res) => {
|
||||||
res.sendFile(__dirname + '/htmls/og-title.html');
|
res.sendFile(__dirname + '/htmls/og-title.html');
|
||||||
});
|
});
|
||||||
const server = app.listen(port, async () => {
|
const server = app.listen(port, async () => {
|
||||||
@ -41,7 +68,7 @@ describe('OGP', () => {
|
|||||||
|
|
||||||
it('description', done => {
|
it('description', done => {
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use((req, res) => {
|
app.get('/', (req, res) => {
|
||||||
res.sendFile(__dirname + '/htmls/og-description.html');
|
res.sendFile(__dirname + '/htmls/og-description.html');
|
||||||
});
|
});
|
||||||
const server = app.listen(port, async () => {
|
const server = app.listen(port, async () => {
|
||||||
@ -54,7 +81,7 @@ describe('OGP', () => {
|
|||||||
|
|
||||||
it('site_name', done => {
|
it('site_name', done => {
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use((req, res) => {
|
app.get('/', (req, res) => {
|
||||||
res.sendFile(__dirname + '/htmls/og-site_name.html');
|
res.sendFile(__dirname + '/htmls/og-site_name.html');
|
||||||
});
|
});
|
||||||
const server = app.listen(port, async () => {
|
const server = app.listen(port, async () => {
|
||||||
@ -67,7 +94,7 @@ describe('OGP', () => {
|
|||||||
|
|
||||||
it('thumbnail', done => {
|
it('thumbnail', done => {
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use((req, res) => {
|
app.get('/', (req, res) => {
|
||||||
res.sendFile(__dirname + '/htmls/og-image.html');
|
res.sendFile(__dirname + '/htmls/og-image.html');
|
||||||
});
|
});
|
||||||
const server = app.listen(port, async () => {
|
const server = app.listen(port, async () => {
|
||||||
@ -82,7 +109,7 @@ describe('OGP', () => {
|
|||||||
describe('TwitterCard', () => {
|
describe('TwitterCard', () => {
|
||||||
it('title', done => {
|
it('title', done => {
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use((req, res) => {
|
app.get('/', (req, res) => {
|
||||||
res.sendFile(__dirname + '/htmls/twitter-title.html');
|
res.sendFile(__dirname + '/htmls/twitter-title.html');
|
||||||
});
|
});
|
||||||
const server = app.listen(port, async () => {
|
const server = app.listen(port, async () => {
|
||||||
@ -95,7 +122,7 @@ describe('TwitterCard', () => {
|
|||||||
|
|
||||||
it('description', done => {
|
it('description', done => {
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use((req, res) => {
|
app.get('/', (req, res) => {
|
||||||
res.sendFile(__dirname + '/htmls/twitter-description.html');
|
res.sendFile(__dirname + '/htmls/twitter-description.html');
|
||||||
});
|
});
|
||||||
const server = app.listen(port, async () => {
|
const server = app.listen(port, async () => {
|
||||||
@ -108,7 +135,7 @@ describe('TwitterCard', () => {
|
|||||||
|
|
||||||
it('thumbnail', done => {
|
it('thumbnail', done => {
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use((req, res) => {
|
app.get('/', (req, res) => {
|
||||||
res.sendFile(__dirname + '/htmls/twitter-image.html');
|
res.sendFile(__dirname + '/htmls/twitter-image.html');
|
||||||
});
|
});
|
||||||
const server = app.listen(port, async () => {
|
const server = app.listen(port, async () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user