mirror of
https://github.com/misskey-dev/summaly.git
synced 2025-08-02 22:36:34 +09:00
🍕
This commit is contained in:
9
test/htmls/dirty-title.html
Normal file
9
test/htmls/dirty-title.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta property="og:site_name" content="Alice's Site">
|
||||
<title>Strawberry Pasta | Alice's Site</title>
|
||||
</head>
|
||||
</html>
|
@ -23,6 +23,12 @@ process.on('unhandledRejection', console.dir);
|
||||
const port = 3000;
|
||||
const host = `http://localhost:${port}`;
|
||||
|
||||
let server;
|
||||
|
||||
afterEach(() => {
|
||||
server.close();
|
||||
});
|
||||
|
||||
/* tests below */
|
||||
|
||||
it('faviconがHTML上で指定されていないが、ルートに存在する場合、正しく設定される', done => {
|
||||
@ -31,10 +37,9 @@ it('faviconがHTML上で指定されていないが、ルートに存在する
|
||||
res.sendFile(__dirname + '/htmls/no-favicon.html');
|
||||
});
|
||||
app.get('/favicon.ico', (_, res) => res.sendStatus(200));
|
||||
const server = app.listen(port, async () => {
|
||||
server = app.listen(port, async () => {
|
||||
const summary = await summaly(host);
|
||||
assert.equal(summary.icon, `${host}/favicon.ico`);
|
||||
server.close();
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -44,10 +49,21 @@ it('faviconがHTML上で指定されていなくて、ルートにも存在し
|
||||
app.get('/', (req, res) => {
|
||||
res.sendFile(__dirname + '/htmls/no-favicon.html');
|
||||
});
|
||||
const server = app.listen(port, async () => {
|
||||
server = app.listen(port, async () => {
|
||||
const summary = await summaly(host);
|
||||
assert.equal(summary.icon, null);
|
||||
server.close();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('titleがcleanupされる', done => {
|
||||
const app = express();
|
||||
app.get('/', (req, res) => {
|
||||
res.sendFile(__dirname + '/htmls/dirty-title.html');
|
||||
});
|
||||
server = app.listen(port, async () => {
|
||||
const summary = await summaly(host);
|
||||
assert.equal(summary.title, 'Strawberry Pasta');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -58,10 +74,9 @@ describe('OGP', () => {
|
||||
app.get('/', (req, res) => {
|
||||
res.sendFile(__dirname + '/htmls/og-title.html');
|
||||
});
|
||||
const server = app.listen(port, async () => {
|
||||
server = app.listen(port, async () => {
|
||||
const summary = await summaly(host);
|
||||
assert.equal(summary.title, 'Strawberry Pasta');
|
||||
server.close();
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -71,10 +86,9 @@ describe('OGP', () => {
|
||||
app.get('/', (req, res) => {
|
||||
res.sendFile(__dirname + '/htmls/og-description.html');
|
||||
});
|
||||
const server = app.listen(port, async () => {
|
||||
server = app.listen(port, async () => {
|
||||
const summary = await summaly(host);
|
||||
assert.equal(summary.description, 'Strawberry Pasta');
|
||||
server.close();
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -84,10 +98,9 @@ describe('OGP', () => {
|
||||
app.get('/', (req, res) => {
|
||||
res.sendFile(__dirname + '/htmls/og-site_name.html');
|
||||
});
|
||||
const server = app.listen(port, async () => {
|
||||
server = app.listen(port, async () => {
|
||||
const summary = await summaly(host);
|
||||
assert.equal(summary.sitename, 'Strawberry Pasta');
|
||||
server.close();
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -97,10 +110,9 @@ describe('OGP', () => {
|
||||
app.get('/', (req, res) => {
|
||||
res.sendFile(__dirname + '/htmls/og-image.html');
|
||||
});
|
||||
const server = app.listen(port, async () => {
|
||||
server = app.listen(port, async () => {
|
||||
const summary = await summaly(host);
|
||||
assert.equal(summary.thumbnail, 'https://himasaku.net/himasaku.png');
|
||||
server.close();
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -112,10 +124,9 @@ describe('TwitterCard', () => {
|
||||
app.get('/', (req, res) => {
|
||||
res.sendFile(__dirname + '/htmls/twitter-title.html');
|
||||
});
|
||||
const server = app.listen(port, async () => {
|
||||
server = app.listen(port, async () => {
|
||||
const summary = await summaly(host);
|
||||
assert.equal(summary.title, 'Strawberry Pasta');
|
||||
server.close();
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -125,10 +136,9 @@ describe('TwitterCard', () => {
|
||||
app.get('/', (req, res) => {
|
||||
res.sendFile(__dirname + '/htmls/twitter-description.html');
|
||||
});
|
||||
const server = app.listen(port, async () => {
|
||||
server = app.listen(port, async () => {
|
||||
const summary = await summaly(host);
|
||||
assert.equal(summary.description, 'Strawberry Pasta');
|
||||
server.close();
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -138,10 +148,9 @@ describe('TwitterCard', () => {
|
||||
app.get('/', (req, res) => {
|
||||
res.sendFile(__dirname + '/htmls/twitter-image.html');
|
||||
});
|
||||
const server = app.listen(port, async () => {
|
||||
server = app.listen(port, async () => {
|
||||
const summary = await summaly(host);
|
||||
assert.equal(summary.thumbnail, 'https://himasaku.net/himasaku.png');
|
||||
server.close();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user