Skip to content

Commit

Permalink
Avoid non deterministic date
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Jan 5, 2018
1 parent c8609cd commit 3fc6130
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 154 deletions.
22 changes: 16 additions & 6 deletions packages/metascraper-amazon/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const snapshot = require('snap-shot')
const { promisify } = require('util')
const { resolve } = require('path')
const { omit } = require('lodash')
const should = require('should')
const fs = require('fs')

const readFile = promisify(fs.readFile)
Expand Down Expand Up @@ -35,16 +36,22 @@ describe('metascraper amazon integration', () => {
const metascraper = require('metascraper')
const html = await readFile(resolve(__dirname, 'fixtures/amazon-com/ansi-url.html'))
const url = 'https://www.amazon.com/gp/product/B0057OC5O8/'
const meta = omit(await metascraper({ html, url }), ['date'])
snapshot(meta)
const metadata = await metascraper({ html, url })

// omit date because it is non deterministic
snapshot(omit(metadata, ['date']))
should(metadata.date).instanceOf(String)
})

it('product url', async () => {
const metascraper = require('metascraper')
const html = await readFile(resolve(__dirname, 'fixtures/amazon-com/product-url.html'))
const url = 'https://www.amazon.com/The-Whole-Truth-Shaw-Book-ebook/dp/B0011UCPM4/ref=pd_zg_rss_ts_b_17_6?ie=UTF8&tag=recomshop-22'
const meta = omit(await metascraper({ html, url }), ['date'])
snapshot(meta)
const metadata = await metascraper({ html, url })

// omit date because it is non deterministic
snapshot(omit(metadata, ['date']))
should(metadata.date).instanceOf(String)
})
})

Expand All @@ -53,8 +60,11 @@ describe('metascraper amazon integration', () => {
const metascraper = require('metascraper')
const html = await readFile(resolve(__dirname, 'fixtures/amazon-es/product-url.html'))
const url = 'https://www.amazon.es/aspirador-Excellence-Programable-limpieza-Silencioso/dp/B01MUGXRT9'
const meta = omit(await metascraper({ html, url }), ['date'])
snapshot(meta)
const metadata = await metascraper({ html, url })

// omit date because it is non deterministic
snapshot(omit(metadata, ['date']))
should(metadata.date).instanceOf(String)
})
})
})
Loading

0 comments on commit 3fc6130

Please sign in to comment.