forked from MONEI/Shopify-api-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfulfillment-event.test.js
More file actions
106 lines (82 loc) · 3.13 KB
/
fulfillment-event.test.js
File metadata and controls
106 lines (82 loc) · 3.13 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
describe('Shopify#fulfillmentEvent', () => {
'use strict';
const expect = require('chai').expect;
const fixtures = require('./fixtures/fulfillment-event');
const common = require('./common');
const Shopify = require('..');
const accessToken = common.accessToken;
const apiVersion = common.apiVersion;
const scope = common.scope;
const shopify = common.shopify;
const shopName = common.shopName;
afterEach(() => expect(scope.isDone()).to.be.true);
it('gets a list of all fulfillments events for a fulfillment (1/2)', () => {
const output = fixtures.res.list;
scope
.get('/admin/orders/450789469/fulfillments/255858046/events.json')
.reply(200, output);
return shopify.fulfillmentEvent
.list(450789469, 255858046)
.then((data) => expect(data).to.deep.equal(output.fulfillment_events));
});
it('gets a list of all fulfillments events for a fulfillment (2/2)', () => {
const output = fixtures.res.list;
scope
.get('/admin/orders/450789469/fulfillments/255858046/events.json?foo=bar')
.reply(200, output);
return shopify.fulfillmentEvent
.list(450789469, 255858046, { foo: 'bar' })
.then((data) => expect(data).to.deep.equal(output.fulfillment_events));
});
it('gets a single fulfillment event by its ID', () => {
const output = fixtures.res.get;
scope
.get('/admin/orders/450789469/fulfillments/255858046/events/3.json')
.reply(200, output);
return shopify.fulfillmentEvent
.get(450789469, 255858046, 3)
.then((data) => expect(data).to.deep.equal(output.fulfillment_event));
});
it('create a fulfillment event', () => {
const input = fixtures.req.create;
const output = fixtures.res.create;
scope
.post('/admin/orders/450789469/fulfillments/255858046/events.json', input)
.reply(201, output);
return shopify.fulfillmentEvent
.create(450789469, 255858046, input.event)
.then((data) => expect(data).to.deep.equal(output.fulfillment_event));
});
it('updates a fulfillment event', () => {
const input = fixtures.req.update;
const output = fixtures.res.update;
scope
.put(
'/admin/orders/450789469/fulfillments/255858046/events/1.json',
input
)
.reply(200, output);
return shopify.fulfillmentEvent
.update(450789469, 255858046, 1, input.event)
.then((data) => expect(data).to.deep.equal(output.fulfillment_event));
});
it('deletes a fulfillment event', () => {
scope
.delete('/admin/orders/450789469/fulfillments/255858046/events/2.json')
.reply(200, {});
return shopify.fulfillmentEvent
.delete(450789469, 255858046, 2)
.then((data) => expect(data).to.deep.equal({}));
});
it('injects the api version to the request path if provided', () => {
const shopify = new Shopify({ shopName, accessToken, apiVersion });
scope
.delete(
`/admin/api/${apiVersion}/orders/450789469/fulfillments/255858046/events/2.json`
)
.reply(200, {});
return shopify.fulfillmentEvent
.delete(450789469, 255858046, 2)
.then((data) => expect(data).to.deep.equal({}));
});
});