forked from MONEI/Shopify-api-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiscount-code-creation-job.test.js
More file actions
54 lines (41 loc) · 1.53 KB
/
discount-code-creation-job.test.js
File metadata and controls
54 lines (41 loc) · 1.53 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
describe('Shopify#discountCodeCreationJob', () => {
'use strict';
const expect = require('chai').expect;
const fixtures = require('./fixtures/discount-code-creation-job');
const common = require('./common');
const shopify = common.shopify;
const scope = common.scope;
afterEach(() => expect(scope.isDone()).to.be.true);
it('creates a new discount code creation job', () => {
const input = fixtures.req.create;
const output = fixtures.res.create;
scope
.post('/admin/price_rules/507328175/batch.json', input)
.reply(201, output);
return shopify.discountCodeCreationJob
.create(507328175, input.discount_codes)
.then((data) =>
expect(data).to.deep.equal(output.discount_code_creation)
);
});
it('gets a single discount code creation job by its ID', () => {
const output = fixtures.res.get;
scope
.get('/admin/price_rules/507328175/batch/173232803.json')
.reply(200, output);
return shopify.discountCodeCreationJob
.get(507328175, 173232803)
.then((data) =>
expect(data).to.deep.equal(output.discount_code_creation)
);
});
it('gets a list of discount codes for a discount code creation job', () => {
const output = fixtures.res.discountCodes;
scope
.get('/admin/price_rules/507328175/batch/173232803/discount_codes.json')
.reply(200, output);
return shopify.discountCodeCreationJob
.discountCodes(507328175, 173232803)
.then((data) => expect(data).to.deep.equal(output.discount_codes));
});
});