forked from MONEI/Shopify-api-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollection.test.js
More file actions
55 lines (39 loc) · 1.57 KB
/
collection.test.js
File metadata and controls
55 lines (39 loc) · 1.57 KB
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
54
55
describe('Shopify#collection', () => {
'use strict';
const expect = require('chai').expect;
const fixtures = require('./fixtures/collection');
const common = require('./common');
const shopify = common.shopify;
const scope = common.scope;
afterEach(() => expect(scope.isDone()).to.be.true);
it('gets a collection by its ID (1/2)', () => {
const output = fixtures.res.get;
scope.get('/admin/collections/841564295.json').reply(200, output);
return shopify.collection
.get(841564295)
.then((data) => expect(data).to.deep.equal(output.collection));
});
it('gets a collection by its ID (2/2)', () => {
const output = fixtures.res.get;
scope.get('/admin/collections/841564295.json?foo=bar').reply(200, output);
return shopify.collection
.get(841564295, { foo: 'bar' })
.then((data) => expect(data).to.deep.equal(output.collection));
});
it('gets a list of products belonging to a collection (1/2)', () => {
const output = fixtures.res.products;
scope.get('/admin/collections/841564295/products.json').reply(200, output);
return shopify.collection
.products(841564295)
.then((data) => expect(data).to.deep.equal(output.products));
});
it('gets a list of products belonging to a collection (2/2)', () => {
const output = fixtures.res.products;
scope
.get('/admin/collections/841564295/products.json?limit=50')
.reply(200, output);
return shopify.collection
.products(841564295, { limit: 50 })
.then((data) => expect(data).to.deep.equal(output.products));
});
});