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