diff --git a/test/htmls/twitter-description.html b/test/htmls/twitter-description.html new file mode 100644 index 0000000..85ea97e --- /dev/null +++ b/test/htmls/twitter-description.html @@ -0,0 +1,13 @@ + + + + + + + YEE HAW + + +

Yo

+

Hey hey hey syuilo.

+ + diff --git a/test/htmls/twitter-image.html b/test/htmls/twitter-image.html new file mode 100644 index 0000000..5cd3e95 --- /dev/null +++ b/test/htmls/twitter-image.html @@ -0,0 +1,13 @@ + + + + + + + YEE HAW + + +

Yo

+

Hey hey hey syuilo.

+ + diff --git a/test/htmls/twitter-title.html b/test/htmls/twitter-title.html new file mode 100644 index 0000000..f4fd2dc --- /dev/null +++ b/test/htmls/twitter-title.html @@ -0,0 +1,13 @@ + + + + + + + YEE HAW + + +

Yo

+

Hey hey hey syuilo.

+ + diff --git a/test/index.js b/test/index.js index 67844de..8ce31a2 100644 --- a/test/index.js +++ b/test/index.js @@ -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(); + }); + }); +});