Skip to content

Commit f59536d

Browse files
committed
billing invoice tests wip
1 parent 2b2e570 commit f59536d

File tree

4 files changed

+72
-2
lines changed

4 files changed

+72
-2
lines changed

src/billing/layouts/InvoicePage.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ function select(state, ownProps) {
111111
const params = ownProps.params;
112112
const invoiceId = params.invoiceId;
113113
const invoice = state.api.invoices.invoices[invoiceId];
114-
console.log(state);
115114
const items = invoice._items.data;
116115
return {
117116
invoice,

test/billing/layouts/HistoryPage.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from 'react';
22
import sinon from 'sinon';
33
import { mount } from 'enzyme';
44
import { expect } from 'chai';
5-
import moment from 'moment-timezone';
65

76
import { HistoryPage } from '~/billing/layouts/HistoryPage';
87
import { api } from '@/data';
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React from 'react';
2+
import sinon from 'sinon';
3+
import { mount } from 'enzyme';
4+
import { expect } from 'chai';
5+
import moment from 'moment-timezone';
6+
7+
import { InvoicePage } from '~/billing/layouts/InvoicePage';
8+
import { api } from '@/data';
9+
10+
11+
const { invoices } = api;
12+
13+
describe('billing/layouts/InvoicePage', () => {
14+
const sandbox = sinon.sandbox.create();
15+
16+
afterEach(() => {
17+
sandbox.restore();
18+
});
19+
20+
const dispatch = sandbox.spy();
21+
22+
it('renders a list of invoice items', () => {
23+
const page = mount(
24+
<InvoicePage
25+
dispatch={dispatch}
26+
invoices={invoices.invoices}
27+
params={{ invoiceId: 1234 }}
28+
/>
29+
);
30+
31+
expect(page.find('.TableRow').length).to.equal(2);
32+
});
33+
});

test/data/invoices.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,47 @@
1+
export const testItem = {
2+
amount: 7.2,
3+
from: '2017-09-01T04:00:00',
4+
to: '2017-10-01T03:59:59',
5+
label: 'Linode Managed - ln (1234)',
6+
quantity: 720,
7+
type: 'hourly',
8+
unit_price: 0.01,
9+
};
10+
111
export const apiTestInvoice = {
212
date: '2016-12-12T15:07:47',
313
label: 'Invoice #1234',
414
id: 1234,
515
total: 10,
16+
_items: {
17+
data: [
18+
testItem,
19+
{
20+
...testItem,
21+
label: 'Linode 1024 - ln (1234)',
22+
},
23+
{
24+
...testItem,
25+
label: 'Storage Volume - sv (123)',
26+
},
27+
{
28+
...testItem,
29+
label: 'Backup Service - Linode 1024 - ln (1234)',
30+
},
31+
{
32+
...testItem,
33+
label: 'Nodebalancer - nb (432)',
34+
},
35+
{
36+
...testItem,
37+
label: 'Linode 1024 - ln (1235)',
38+
},
39+
{
40+
...testItem,
41+
label: 'Linode 1024 - ln (1236)',
42+
},
43+
],
44+
},
645
};
746

847
export const testInvoice = {

0 commit comments

Comments
 (0)