forked from MONEI/Shopify-api-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfulfillment-order.test.js
More file actions
108 lines (83 loc) · 3.18 KB
/
fulfillment-order.test.js
File metadata and controls
108 lines (83 loc) · 3.18 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
describe('Shopify#fulfillmentOrder', () => {
'use strict';
const expect = require('chai').expect;
const fixtures = require('./fixtures/fulfillment-order');
const common = require('./common');
const shopify = common.shopify;
const scope = common.scope;
afterEach(() => expect(scope.isDone()).to.be.true);
it('gets a list of fulfillment orders on a shop for a specific app', () => {
const output = fixtures.res.list;
scope
.get(
'/admin/assigned_fulfillment_orders.json' +
'?assignment_status=cancellation_requested&location_ids[]=48752903'
)
.reply(200, output);
return shopify.fulfillmentOrder
.list({
assignment_status: 'cancellation_requested',
location_ids: ['48752903']
})
.then((data) => expect(data).to.deep.equal(output.fulfillment_orders));
});
it('gets a single fulfillment order by its ID', () => {
const output = fixtures.res.get;
scope.get('/admin/fulfillment_orders/1025578639.json').reply(200, output);
return shopify.fulfillmentOrder
.get(1025578639)
.then((data) => expect(data).to.deep.equal(output.fulfillment_order));
});
it('cancels a fulfillment order', () => {
const input = fixtures.req.cancel;
const output = fixtures.res.cancel;
scope
.post('/admin/fulfillment_orders/1025578640/cancel.json', input)
.reply(200, output);
return shopify.fulfillmentOrder
.cancel(1025578640, input.fulfillment_order)
.then((data) => expect(data).to.deep.equal(output.fulfillment_order));
});
it('marks a fulfillment order as incomplete (1/2)', () => {
const input = fixtures.req.close;
const output = fixtures.res.close;
scope
.post('/admin/fulfillment_orders/1025578642/close.json', input)
.reply(200, output);
return shopify.fulfillmentOrder
.close(1025578642, 'Not enough inventory to complete this work.')
.then((data) => expect(data).to.deep.equal(output.fulfillment_order));
});
it('marks a fulfillment order as incomplete (2/2)', () => {
const output = fixtures.res.close;
scope
.post('/admin/fulfillment_orders/1025578642/close.json', {
fulfillment_order: { message: '' }
})
.reply(200, output);
return shopify.fulfillmentOrder
.close(1025578642)
.then((data) => expect(data).to.deep.equal(output.fulfillment_order));
});
it('gets a list of locations that a fulfillment order can move to', () => {
const output = fixtures.res.locationsForMove;
scope
.get('/admin/fulfillment_orders/1025578643/locations_for_move.json')
.reply(200, output);
return shopify.fulfillmentOrder
.locationsForMove(1025578643)
.then((data) => {
expect(data).to.deep.equal(output.locations_for_move);
});
});
it('moves a fulfillment order to a new location', () => {
const input = fixtures.req.move;
const output = fixtures.res.move;
scope
.post('/admin/fulfillment_orders/1025578643/move.json', input)
.reply(200, output);
return shopify.fulfillmentOrder.move(1025578643, 905684977).then((data) => {
expect(data).to.deep.equal(output.original_fulfillment_order);
});
});
});