forked from MONEI/Shopify-api-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprice-rule.test.js
More file actions
73 lines (52 loc) · 2.03 KB
/
price-rule.test.js
File metadata and controls
73 lines (52 loc) · 2.03 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
describe('Shopify#priceRule', () => {
'use strict';
const expect = require('chai').expect;
const fixtures = require('./fixtures/price-rule');
const common = require('./common');
const shopify = common.shopify;
const scope = common.scope;
afterEach(() => expect(scope.isDone()).to.be.true);
it('creates a new price rule', () => {
const input = fixtures.req.create;
const output = fixtures.res.create;
scope.post('/admin/price_rules.json', input).reply(201, output);
return shopify.priceRule
.create(input.price_rule)
.then((data) => expect(data).to.deep.equal(output.price_rule));
});
it('updates a price rule', () => {
const input = fixtures.req.update;
const output = fixtures.res.update;
scope.put('/admin/price_rules/2762402181.json', input).reply(200, output);
return shopify.priceRule
.update(2762402181, input.price_rule)
.then((data) => expect(data).to.deep.equal(output.price_rule));
});
it('gets a list of price rule objects (1/2)', () => {
const output = fixtures.res.list;
scope.get('/admin/price_rules.json').reply(200, output);
return shopify.priceRule
.list()
.then((data) => expect(data).to.deep.equal(output.price_rules));
});
it('gets a list of price rule objects (2/2)', () => {
const output = fixtures.res.list;
scope.get('/admin/price_rules.json?limit=25').reply(200, output);
return shopify.priceRule
.list({ limit: 25 })
.then((data) => expect(data).to.deep.equal(output.price_rules));
});
it('gets a single price rule by its ID', () => {
const output = fixtures.res.get;
scope.get('/admin/price_rules/2762402181.json').reply(200, output);
return shopify.priceRule
.get(2762402181)
.then((data) => expect(data).to.deep.equal(output.price_rule));
});
it('deletes a price rule', () => {
scope.delete('/admin/price_rules/2762402181.json').reply(200);
return shopify.priceRule
.delete(2762402181)
.then((data) => expect(data).to.deep.equal({}));
});
});