[Test] Add some twitter cards tests

This commit is contained in:
syuilo 2017-02-08 21:33:37 +09:00
parent 814a5eb092
commit ac5e6230f6
4 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta property="twitter:description" content="Strawberry Pasta">
<title>YEE HAW</title>
</head>
<body>
<h1>Yo</h1>
<p>Hey hey hey syuilo.</p>
</body>
</html>

View File

@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta property="twitter:image" content="https://himasaku.net/himasaku.png">
<title>YEE HAW</title>
</head>
<body>
<h1>Yo</h1>
<p>Hey hey hey syuilo.</p>
</body>
</html>

View File

@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta property="twitter:title" content="Strawberry Pasta">
<title>YEE HAW</title>
</head>
<body>
<h1>Yo</h1>
<p>Hey hey hey syuilo.</p>
</body>
</html>

View File

@ -78,3 +78,44 @@ describe('OGP', () => {
});
});
});
describe('TwitterCard', () => {
it('title', done => {
const app = express();
app.use((req, res) => {
res.sendFile(__dirname + '/htmls/twitter-title.html');
});
const server = app.listen(port, async () => {
const summary = await summaly(host);
assert.equal(summary.title, 'Strawberry Pasta');
server.close();
done();
});
});
it('description', done => {
const app = express();
app.use((req, res) => {
res.sendFile(__dirname + '/htmls/twitter-description.html');
});
const server = app.listen(port, async () => {
const summary = await summaly(host);
assert.equal(summary.description, 'Strawberry Pasta');
server.close();
done();
});
});
it('thumbnail', done => {
const app = express();
app.use((req, res) => {
res.sendFile(__dirname + '/htmls/twitter-image.html');
});
const server = app.listen(port, async () => {
const summary = await summaly(host);
assert.equal(summary.thumbnail, 'https://himasaku.net/himasaku.png');
server.close();
done();
});
});
});