forked from MONEI/Shopify-api-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocation.test.js
More file actions
65 lines (46 loc) · 1.79 KB
/
location.test.js
File metadata and controls
65 lines (46 loc) · 1.79 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
56
57
58
59
60
61
62
63
64
65
describe('Shopify#location', () => {
'use strict';
const expect = require('chai').expect;
const fixtures = require('./fixtures/location');
const common = require('./common');
const shopify = common.shopify;
const scope = common.scope;
afterEach(() => expect(scope.isDone()).to.be.true);
it('gets a list of all locations', () => {
const output = fixtures.res.list;
scope.get('/admin/locations.json').reply(200, output);
return shopify.location
.list()
.then((data) => expect(data).to.deep.equal(output.locations));
});
it('gets a single location by its ID', () => {
const output = fixtures.res.get;
scope.get('/admin/locations/487838322.json').reply(200, output);
return shopify.location
.get(487838322)
.then((data) => expect(data).to.deep.equal(output.location));
});
it('gets a count of locations', () => {
const output = { count: 4 };
scope.get('/admin/locations/count.json').reply(200, output);
return shopify.location.count().then((data) => expect(data).to.equal(4));
});
it('gets a list of inventory levels for a location (1/2)', () => {
const output = fixtures.res.inventoryLevels;
scope
.get('/admin/locations/487838322/inventory_levels.json')
.reply(200, output);
return shopify.location
.inventoryLevels(487838322)
.then((data) => expect(data).to.deep.equal(output.inventory_levels));
});
it('gets a list of inventory levels for a location (2/2)', () => {
const output = fixtures.res.inventoryLevels;
scope
.get('/admin/locations/487838322/inventory_levels.json?limit=50')
.reply(200, output);
return shopify.location
.inventoryLevels(487838322, { limit: 50 })
.then((data) => expect(data).to.deep.equal(output.inventory_levels));
});
});