From 0149fa7f2ace6e56a283e330e3320fac3be5032c Mon Sep 17 00:00:00 2001 From: sachaaaaa Date: Tue, 27 Aug 2019 11:35:11 +1000 Subject: [PATCH] Expand link preview tests for tenor and giphy --- test/modules/link_previews_test.js | 57 +++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/test/modules/link_previews_test.js b/test/modules/link_previews_test.js index 0cae46b93..f88c371e6 100644 --- a/test/modules/link_previews_test.js +++ b/test/modules/link_previews_test.js @@ -192,7 +192,7 @@ describe('Link previews', () => { ); }); - it('returns html-decoded tag contents from Instagram', () => { + it('returns html-decoded tag contents from Imgur', () => { const imgur = ` @@ -211,6 +211,50 @@ describe('Link previews', () => { ); }); + it('returns html-decoded tag contents from Giphy', () => { + const giphy = ` + + + + + + + + + `; + + assert.strictEqual( + 'I Cant Hear You Kobe Bryant GIF - Find & Share on GIPHY', + getTitleMetaTag(giphy) + ); + assert.strictEqual( + 'https://media.giphy.com/media/3o7qE8mq5bT9FQj7j2/giphy.gif', + getImageMetaTag(giphy) + ); + }); + + it('returns html-decoded tag contents from Tenor', () => { + const tenor = ` + + + + + + + + + `; + + assert.strictEqual( + 'Hopping Jumping GIF - Hopping Jumping Bird - Discover & Share GIFs', + getTitleMetaTag(tenor) + ); + assert.strictEqual( + 'https://media1.tenor.com/images/3772949a5b042e626d259f313fd1e9b8/tenor.gif?itemid=14834517', + getImageMetaTag(tenor) + ); + }); + it('returns only the first tag', () => { const html = ` @@ -229,6 +273,17 @@ describe('Link previews', () => { getTitleMetaTag(html) ); }); + + it('converts image url protocol http to https', () => { + const html = ` + + `; + + assert.strictEqual( + 'https://giphygifs.s3.amazonaws.com/media/APcFiiTrG0x2/200.gif', + getImageMetaTag(html) + ); + }); }); describe('#findLinks', () => {