forked from MONEI/Shopify-api-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpayment.test.js
More file actions
64 lines (48 loc) · 1.75 KB
/
payment.test.js
File metadata and controls
64 lines (48 loc) · 1.75 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
describe('Shopify#payment', () => {
'use strict';
const expect = require('chai').expect;
const fixtures = require('./fixtures/payment');
const common = require('./common');
const shopify = common.shopify;
const scope = common.scope;
afterEach(() => expect(scope.isDone()).to.be.true);
it('gets a list of payments on a particular checkout', () => {
const output = fixtures.res.list;
scope
.get('/admin/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments.json')
.reply(200, output);
return shopify.payment
.list('7yjf4v2we7gamku6a6h7tvm8h3mmvs4x')
.then((data) => expect(data).to.deep.equal(output.payments));
});
it('creates a new payment', () => {
const token = '7yjf4v2we7gamku6a6h7tvm8h3mmvs4x';
const input = fixtures.req.create;
const output = fixtures.res.create;
scope
.post(`/admin/checkouts/${token}/payments.json`, input)
.reply(201, output);
return shopify.payment
.create(token, input.payment)
.then((data) => expect(data).to.deep.equal(output.payment));
});
it('gets a single payment by its ID', () => {
const token = '7yjf4v2we7gamku6a6h7tvm8h3mmvs4x';
const output = fixtures.res.get;
scope
.get(`/admin/checkouts/${token}/payments/25428999.json`)
.reply(200, output);
return shopify.payment
.get(token, 25428999)
.then((data) => expect(data).to.deep.equal(output.payment));
});
it('counts the number of payments attempted on a checkout', () => {
const token = '7yjf4v2we7gamku6a6h7tvm8h3mmvs4x';
scope
.get(`/admin/checkouts/${token}/payments/count.json`)
.reply(200, { count: 1 });
return shopify.payment
.count(token)
.then((data) => expect(data).to.equal(1));
});
});