-
Notifications
You must be signed in to change notification settings - Fork 768
/
Copy pathCreditNotes.spec.js
119 lines (110 loc) · 2.94 KB
/
CreditNotes.spec.js
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
'use strict';
const stripe = require('../testUtils.js').getSpyableStripe();
const expect = require('chai').expect;
describe('CreditNotes Resource', () => {
describe('retrieve', () => {
it('Sends the correct request', () => {
stripe.creditNotes.retrieve('cn_123');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/credit_notes/cn_123',
headers: {},
data: null,
settings: {},
});
});
});
describe('create', () => {
it('Sends the correct request', () => {
const data = {
amount: 100,
invoice: 'in_123',
reason: 'duplicate',
};
stripe.creditNotes.create(data);
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/credit_notes',
headers: {},
data,
settings: {},
});
});
});
describe('list', () => {
it('Sends the correct request', () => {
stripe.creditNotes.list({count: 25});
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/credit_notes?count=25',
headers: {},
data: null,
settings: {},
});
});
});
describe('listLineItems', () => {
it('Sends the correct request', () => {
stripe.creditNotes.listLineItems('cn_123');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/credit_notes/cn_123/lines',
headers: {},
data: null,
settings: {},
});
});
});
describe('listPreviewLineItems', () => {
it('Sends the correct request', () => {
stripe.creditNotes.listPreviewLineItems();
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/credit_notes/preview/lines',
headers: {},
data: null,
settings: {},
});
});
});
describe('update', () => {
it('Sends the correct request', () => {
stripe.creditNotes.update('cn_123', {application_fee: 200});
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/credit_notes/cn_123',
headers: {},
data: {application_fee: 200},
settings: {},
});
});
});
describe('preview', () => {
it('Sends the correct request', () => {
const data = {
amount: 100,
invoice: 'in_123',
};
stripe.creditNotes.preview(data);
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/credit_notes/preview?amount=100&invoice=in_123',
headers: {},
data: null,
settings: {},
});
});
});
describe('voidCreditNote', () => {
it('Sends the correct request', () => {
stripe.creditNotes.voidCreditNote('cn_123');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/credit_notes/cn_123/void',
headers: {},
data: {},
settings: {},
});
});
});
});