From 5b1ecfdf2003e3087dedb220359a5247665a52bc Mon Sep 17 00:00:00 2001 From: Kiko Beats Date: Thu, 13 Jun 2019 00:37:35 +0200 Subject: [PATCH] test: use a valid mp4 video url --- .editorconfig | 2 +- src/html.js | 8 ++++++-- test/index.js | 35 +++++++++++++++++++++++++++-------- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/.editorconfig b/.editorconfig index c3efa59..0d8138e 100755 --- a/.editorconfig +++ b/.editorconfig @@ -9,7 +9,7 @@ end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true -max_line_length = 100 +max_line_length = 80 indent_brace_style = 1TBS spaces_around_operators = true quote_type = auto diff --git a/src/html.js b/src/html.js index 5d55abf..d79d485 100644 --- a/src/html.js +++ b/src/html.js @@ -62,7 +62,9 @@ const addMedia = (media, { $, url, headers, body }) => { const ogMediaType = $(`meta[property="og:${media}:type"]`) if (!ogMediaType.length) { - tags.push(``) + tags.push( + `` + ) } const head = $('head') @@ -87,7 +89,9 @@ const htmlTemplate = () => ` module.exports = ({ html, url, headers }) => { const contentType = headers['content-type'] || 'text/html' const hasHTML = - mimeTypes.extension(contentType) === 'html' && typeof html === 'string' && html.length > 0 + mimeTypes.extension(contentType) === 'html' && + typeof html === 'string' && + html.length > 0 const content = hasHTML ? html : htmlTemplate() diff --git a/test/index.js b/test/index.js index c5cfe45..386e4e4 100644 --- a/test/index.js +++ b/test/index.js @@ -64,16 +64,28 @@ test('unreachable urls', async t => { ` - t.deepEqual(prettyHtml(await wait(getHTML(url, { prerender: false }), 'html')), prettyHtml(html)) - t.deepEqual(prettyHtml(await wait(getHTML(url, { prerender: true }), 'html')), prettyHtml(html)) + t.deepEqual( + prettyHtml(await wait(getHTML(url, { prerender: false }), 'html')), + prettyHtml(html) + ) + t.deepEqual( + prettyHtml(await wait(getHTML(url, { prerender: true }), 'html')), + prettyHtml(html) + ) }) test('decode base64 entities', async t => { const url = 'https://gist.githubusercontent.com/Kikobeats/912a6c2158de3f3c30d0d7c7697af393/raw/d47d9df77696d9a42df192b7aedbf6cfd2ad393e/index.html' - const fetch = prettyHtml(await wait(getHTML(url, { prerender: false }), 'html')) - t.true(fetch.includes('')) + const fetch = prettyHtml( + await wait(getHTML(url, { prerender: false }), 'html') + ) + t.true( + fetch.includes( + '' + ) + ) t.true(fetch.includes('')) @@ -88,8 +100,14 @@ test('decode base64 entities', async t => { ) ) - const prerender = prettyHtml(await wait(getHTML(url, { prerender: false }), 'html')) - t.true(prerender.includes('')) + const prerender = prettyHtml( + await wait(getHTML(url, { prerender: false }), 'html') + ) + t.true( + prerender.includes( + '' + ) + ) t.true(prerender.includes('')) @@ -106,7 +124,8 @@ test('decode base64 entities', async t => { }) test('unencoded URL', async t => { - const url = 'https://medium.com/@Acegikmo/the-ever-so-lovely-bézier-curve-eb27514da3bf' + const url = + 'https://medium.com/@Acegikmo/the-ever-so-lovely-bézier-curve-eb27514da3bf' t.is( await wait(getHTML(url, { prerender: false }), 'url'), 'https://medium.com/@Acegikmo/the-ever-so-lovely-b%C3%A9zier-curve-eb27514da3bf' @@ -136,7 +155,7 @@ test('get html from image url', async t => { }) test('get html from video url', async t => { - const url = 'https://cdn.microlink.io/meta/preview.mp4' + const url = 'http://techslides.com/demos/sample-videos/small.mp4' const { url: urlDetected, stats, html } = await getHTML(url, { prerender: false })