forked from MONEI/Shopify-api-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinventory-level.test.js
More file actions
77 lines (58 loc) · 2.16 KB
/
inventory-level.test.js
File metadata and controls
77 lines (58 loc) · 2.16 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
66
67
68
69
70
71
72
73
74
75
76
77
describe('Shopify#inventoryLevel', () => {
'use strict';
const expect = require('chai').expect;
const qs = require('qs');
const fixtures = require('./fixtures/inventory-level');
const common = require('./common');
const shopify = common.shopify;
const scope = common.scope;
afterEach(() => expect(scope.isDone()).to.be.true);
it('gets a list of inventory levels', () => {
const query = { inventory_item_ids: 808950810 };
const output = fixtures.res.list;
scope
.get('/admin/inventory_levels.json?' + qs.stringify(query))
.reply(200, output);
return shopify.inventoryLevel
.list(query)
.then((data) => expect(data).to.deep.equal(output.inventory_levels));
});
it('adjusts the inventory level for an inventory item at a location', () => {
const input = fixtures.req.adjust;
const output = fixtures.res.adjust;
scope.post('/admin/inventory_levels/adjust.json', input).reply(200, output);
return shopify.inventoryLevel
.adjust(input)
.then((data) => expect(data).to.deep.equal(output.inventory_level));
});
it('removes an inventory level from a location', () => {
const query = {
inventory_item_id: 808950810,
location_id: 905684977
};
scope
.delete('/admin/inventory_levels.json?' + qs.stringify(query))
.reply(204);
return shopify.inventoryLevel
.delete(query)
.then((data) => expect(data).to.deep.equal({}));
});
it('connects an inventory item to a location', () => {
const input = fixtures.req.connect;
const output = fixtures.res.connect;
scope
.post('/admin/inventory_levels/connect.json', input)
.reply(201, output);
return shopify.inventoryLevel
.connect(input)
.then((data) => expect(data).to.deep.equal(output.inventory_level));
});
it('sets the inventory level for an inventory item at a location', () => {
const input = fixtures.req.set;
const output = fixtures.res.set;
scope.post('/admin/inventory_levels/set.json', input).reply(200, output);
return shopify.inventoryLevel
.set(input)
.then((data) => expect(data).to.deep.equal(output.inventory_level));
});
});