/
zinc-fetch.test.js
53 lines (44 loc) · 1.56 KB
/
zinc-fetch.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
'use strict'
const Bluebird = require('bluebird'),
should = require('should'),
sinon = require('sinon'),
// Set your own here, or just make sure that the test can pick up
// your api key wherever you manage it
zincKey = process.env.ZINC_KEY,
_ = require('lodash'),
ZincFetch = require('../lib/zinc-fetch')(zincKey);
describe('The zinc wrapper', () => {
it(`should have its main domains`, () => {
should.exist(ZincFetch.order);
should.exist(ZincFetch.product);
});
it(`should have its basic functions`, () => {
_.forEach(ZincFetch.order, func => {
(func).should.be.a.Function();
});
_.forEach(ZincFetch.product, func => {
(func).should.be.a.Function();
});
});
describe(`The product functions`, () => {
it(`should get product details`, (done) => {
if (zincKey) {
ZincFetch.product.getDetails('0060512806').then(response => {
should.exist(response);
should.equal('completed', response.status);
should.equal('amazon', response.retailer);
should.equal('Cryptonomicon', response.title);
done();
});
}
});
it(`should get product details`, (done) => {
if (zincKey) {
ZincFetch.product.getPrices('0060512806').then(response => {
should.exist(response);
done();
});
}
});
});
});