From 28cf41304ca2fa9397166669f4f19169a542cf78 Mon Sep 17 00:00:00 2001 From: Jad Termsani <32297675+JadTermsani@users.noreply.github.com> Date: Thu, 24 Jan 2019 12:16:31 +0200 Subject: [PATCH] fix: timezone comparison (#222) * fix: use format() instead of toISOString() * fix: timezone comparison --- src/extractors/custom/www.msn.com/index.test.js | 4 +++- src/extractors/generic/index.test.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/extractors/custom/www.msn.com/index.test.js b/src/extractors/custom/www.msn.com/index.test.js index cc4fad10..dd041851 100644 --- a/src/extractors/custom/www.msn.com/index.test.js +++ b/src/extractors/custom/www.msn.com/index.test.js @@ -1,6 +1,7 @@ import assert from 'assert'; import URL from 'url'; import cheerio from 'cheerio'; +import moment from 'moment'; import Mercury from 'mercury'; import getExtractor from 'extractors/get-extractor'; @@ -57,10 +58,11 @@ describe('MSNExtractor', () => { // To pass this test, fill out the date_published selector // in ./src/extractors/custom/www.msn.com/index.js. const { date_published } = await result; + const newDatePublished = moment(date_published).format(); // Update these values with the expected values from // the article. - assert.equal(date_published.split('T')[0], '2016-09-21'); + assert.equal(newDatePublished.split('T')[0], '2016-09-21'); }); it('returns the lead_image_url', async () => { diff --git a/src/extractors/generic/index.test.js b/src/extractors/generic/index.test.js index f8252784..8b1ede6d 100644 --- a/src/extractors/generic/index.test.js +++ b/src/extractors/generic/index.test.js @@ -1,4 +1,5 @@ import assert from 'assert'; +import moment from 'moment'; import GenericExtractor from './index'; @@ -14,13 +15,14 @@ describe('GenericExtractor', () => { html, metaCache: [], }); + const newDatePublished = moment(date_published).format(); assert.equal(author, null); assert.equal( title, 'California appears poised to be first to ban power-guzzling big-screen TVs' ); - assert.equal(date_published.split('T')[0], '2009-10-14'); + assert.equal(newDatePublished.split('T')[0], '2009-10-14'); assert.equal(dek, null); });