forked from MONEI/Shopify-api-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproduct-listing.test.js
More file actions
178 lines (134 loc) · 5.3 KB
/
product-listing.test.js
File metadata and controls
178 lines (134 loc) · 5.3 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
describe('Shopify#productListing', () => {
'use strict';
const expect = require('chai').expect;
const fixtures = require('./fixtures/product-listing');
const common = require('./common');
const shopify = common.shopify;
const shopifyWithPresenmentOption = common.shopifyWithPresentmentOption;
const standardScope = common.scope;
const presentmentApiScope = common.presentmentApiScope;
afterEach(() => {
expect(presentmentApiScope.isDone()).to.be.true;
expect(standardScope.isDone()).to.be.true;
});
it('gets product listings published to an application (1/4)', () => {
const output = fixtures.res.list;
standardScope.get('/admin/product_listings.json').reply(200, output);
return shopify.productListing
.list()
.then((data) => expect(data).to.deep.equal(output.product_listings));
});
it('gets product listings published to an application (2/4)', () => {
const output = fixtures.res.list;
standardScope.get('/admin/product_listings.json?page=1').reply(200, output);
return shopify.productListing
.list({ page: 1 })
.then((data) => expect(data).to.deep.equal(output.product_listings));
});
it('gets product listings published to an application (3/4)', () => {
const output = fixtures.res.list;
presentmentApiScope.get('/admin/product_listings.json').reply(200, output);
return shopifyWithPresenmentOption.productListing
.list()
.then((data) => expect(data).to.deep.equal(output.product_listings));
});
it('gets product listings published to an application (4/4)', () => {
const output = fixtures.res.list;
presentmentApiScope
.get('/admin/product_listings.json?page=1')
.reply(200, output);
return shopifyWithPresenmentOption.productListing
.list({ page: 1 })
.then((data) => expect(data).to.deep.equal(output.product_listings));
});
it('gets product IDs published to an application (1/2)', () => {
const output = fixtures.res.productIds;
standardScope
.get('/admin/product_listings/product_ids.json')
.reply(200, output);
return shopify.productListing
.productIds()
.then((data) => expect(data).to.deep.equal(output.product_ids));
});
it('gets product IDs published to an application (2/2)', () => {
const output = fixtures.res.productIds;
standardScope
.get('/admin/product_listings/product_ids.json?page=1')
.reply(200, output);
return shopify.productListing
.productIds({ page: 1 })
.then((data) => expect(data).to.deep.equal(output.product_ids));
});
it('gets a count of products published to an application', () => {
standardScope
.get('/admin/product_listings/count.json')
.reply(200, { count: 2 });
return shopify.productListing
.count()
.then((data) => expect(data).to.equal(2));
});
it('gets a specific product listing', () => {
const output = fixtures.res.get;
standardScope
.get('/admin/product_listings/921728736.json')
.reply(200, output);
return shopify.productListing
.get(921728736)
.then((data) => expect(data).to.deep.equal(output.product_listing));
});
it('gets a specific product listing with presentment option', () => {
const output = fixtures.res.get;
presentmentApiScope
.get('/admin/product_listings/921728736.json')
.reply(200, output);
return shopifyWithPresenmentOption.productListing
.get(921728736)
.then((data) => expect(data).to.deep.equal(output.product_listing));
});
it('creates a product listing (1/4)', () => {
const input = fixtures.req.create;
const output = fixtures.res.create;
standardScope
.put('/admin/product_listings/921728736.json', input)
.reply(200, output);
return shopify.productListing
.create(921728736)
.then((data) => expect(data).to.deep.equal(output.product_listing));
});
it('creates a product listing (2/4)', () => {
const input = fixtures.req.create;
const output = fixtures.res.create;
standardScope
.put('/admin/product_listings/921728736.json', input)
.reply(200, output);
return shopify.productListing
.create(921728736, input.product_listing)
.then((data) => expect(data).to.deep.equal(output.product_listing));
});
it('creates a product listing (3/4)', () => {
const input = fixtures.req.create;
const output = fixtures.res.create;
presentmentApiScope
.put('/admin/product_listings/921728736.json', input)
.reply(200, output);
return shopifyWithPresenmentOption.productListing
.create(921728736)
.then((data) => expect(data).to.deep.equal(output.product_listing));
});
it('creates a product listing (4/4)', () => {
const input = fixtures.req.create;
const output = fixtures.res.create;
presentmentApiScope
.put('/admin/product_listings/921728736.json', input)
.reply(200, output);
return shopifyWithPresenmentOption.productListing
.create(921728736, input.product_listing)
.then((data) => expect(data).to.deep.equal(output.product_listing));
});
it('deletes a product listing', () => {
standardScope.delete('/admin/product_listings/921728736.json').reply(200);
return shopify.productListing
.delete(921728736)
.then((data) => expect(data).to.deep.equal({}));
});
});