forked from MONEI/Shopify-api-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrefund.test.js
More file actions
85 lines (63 loc) · 2.29 KB
/
refund.test.js
File metadata and controls
85 lines (63 loc) · 2.29 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
describe('Shopify#refund', () => {
'use strict';
const expect = require('chai').expect;
const fixtures = require('./fixtures/refund');
const common = require('./common');
const shopify = common.shopify;
const scope = common.scope;
afterEach(() => expect(scope.isDone()).to.be.true);
it('gets a list of refunds for an order (1/2)', () => {
const output = fixtures.res.list;
scope.get('/admin/orders/450789469/refunds.json').reply(200, output);
return shopify.refund
.list(450789469)
.then((data) => expect(data).to.deep.equal(output.refunds));
});
it('gets a list of refunds for an order (2/2)', () => {
const output = fixtures.res.list;
scope
.get('/admin/orders/450789469/refunds.json?foo=bar')
.reply(200, output);
return shopify.refund
.list(450789469, { foo: 'bar' })
.then((data) => expect(data).to.deep.equal(output.refunds));
});
it('gets a single refund by its ID (1/2)', () => {
const output = fixtures.res.get;
scope
.get('/admin/orders/450789469/refunds/509562969.json')
.reply(200, output);
return shopify.refund
.get(450789469, 509562969)
.then((data) => expect(data).to.deep.equal(output.refund));
});
it('gets a single refund by its ID (2/2)', () => {
const output = fixtures.res.get;
scope
.get('/admin/orders/450789469/refunds/509562969.json?foo=bar')
.reply(200, output);
return shopify.refund
.get(450789469, 509562969, { foo: 'bar' })
.then((data) => expect(data).to.deep.equal(output.refund));
});
it('calculates a refund', () => {
const input = fixtures.req.calculate;
const output = fixtures.res.calculate;
scope
.post('/admin/orders/450789469/refunds/calculate.json', input)
.reply(200, output);
return shopify.refund
.calculate(450789469, input.refund)
.then((data) => expect(data).to.deep.equal(output.refund));
});
it('creates a refund for an existing order', () => {
const input = fixtures.req.create;
const output = fixtures.res.create;
scope
.post('/admin/orders/450789469/refunds.json', input)
.reply(201, output);
return shopify.refund
.create(450789469, input.refund)
.then((data) => expect(data).to.deep.equal(output.refund));
});
});