forked from MONEI/Shopify-api-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusage-charge.test.js
More file actions
75 lines (56 loc) · 2.1 KB
/
usage-charge.test.js
File metadata and controls
75 lines (56 loc) · 2.1 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
describe('Shopify#usageCharge', () => {
'use strict';
const expect = require('chai').expect;
const fixtures = require('./fixtures/usage-charge');
const common = require('./common');
const parent = 'recurring_application_charges';
const shopify = common.shopify;
const scope = common.scope;
afterEach(() => expect(scope.isDone()).to.be.true);
it('creates a new usage charge', () => {
const input = fixtures.req.create;
const output = fixtures.res.create;
scope
.post(`/admin/${parent}/455696195/usage_charges.json`, input)
.reply(201, output);
return shopify.usageCharge
.create(455696195, input.usage_charge)
.then((data) => expect(data).to.deep.equal(output.usage_charge));
});
it('gets a single usage charge by its ID (1/2)', () => {
const output = fixtures.res.get;
scope
.get(`/admin/${parent}/455696195/usage_charges/329049015.json`)
.reply(200, output);
return shopify.usageCharge
.get(455696195, 329049015)
.then((data) => expect(data).to.deep.equal(output.usage_charge));
});
it('gets a single usage charge by its ID (2/2)', () => {
const output = fixtures.res.get;
scope
.get(`/admin/${parent}/455696195/usage_charges/329049015.json?foo=bar`)
.reply(200, output);
return shopify.usageCharge
.get(455696195, 329049015, { foo: 'bar' })
.then((data) => expect(data).to.deep.equal(output.usage_charge));
});
it('gets a list of all usage charges (1/2)', () => {
const output = fixtures.res.list;
scope
.get(`/admin/${parent}/455696195/usage_charges.json`)
.reply(200, output);
return shopify.usageCharge
.list(455696195)
.then((data) => expect(data).to.deep.equal(output.usage_charges));
});
it('gets a list of all usage charges (2/2)', () => {
const output = fixtures.res.list;
scope
.get(`/admin/${parent}/455696195/usage_charges.json?foo=bar`)
.reply(200, output);
return shopify.usageCharge
.list(455696195, { foo: 'bar' })
.then((data) => expect(data).to.deep.equal(output.usage_charges));
});
});