Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 77bee0b

Browse files
committed
Add unit tests for computed values
1 parent fdccadc commit 77bee0b

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

test/unit/computed/invoice.spec.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,18 @@ describe('Computed Invoice Unit Tests', () => {
1414
expect(store.invoiceAmountLabel, 'to equal', '0');
1515
});
1616

17-
it('should format amount', () => {
17+
it('should format btc amount', () => {
1818
store.invoice.amount = '0.1001';
1919
ComputedInvoice(store);
2020
expect(store.invoiceAmountLabel, 'to match', /^0[,.]1{1}0{2}1{1}$/);
2121
});
22+
23+
it('should format fiat amount', () => {
24+
store.settings.displayFiat = true;
25+
store.settings.exchangeRate.usd = 0.00014503;
26+
store.invoice.amount = '0.1001';
27+
ComputedInvoice(store);
28+
expect(store.invoiceAmountLabel, 'to match', /690[,.]20/);
29+
});
2230
});
2331
});

test/unit/computed/payment.spec.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('Computed Payment Unit Tests', () => {
1616
expect(store.paymentTotalLabel, 'to equal', '0');
1717
});
1818

19-
it('should calculate total', () => {
19+
it('should calculate btc total', () => {
2020
store.payment.fee = '0.0001';
2121
store.payment.amount = '0.1';
2222
ComputedPayment(store);
@@ -25,6 +25,17 @@ describe('Computed Payment Unit Tests', () => {
2525
expect(store.paymentTotalLabel, 'to match', /^0[,.]1{1}0{2}1{1}$/);
2626
});
2727

28+
it('should calculate fiat total', () => {
29+
store.settings.displayFiat = true;
30+
store.settings.exchangeRate.usd = 0.00014503;
31+
store.payment.fee = '0.0001';
32+
store.payment.amount = '0.1';
33+
ComputedPayment(store);
34+
expect(store.paymentAmountLabel, 'to match', /689[,.]51/);
35+
expect(store.paymentFeeLabel, 'to match', /0[,.]69/);
36+
expect(store.paymentTotalLabel, 'to match', /690[,.]20/);
37+
});
38+
2839
it('should ignore fee if blank', () => {
2940
store.payment.fee = '';
3041
store.payment.amount = '0.1';

0 commit comments

Comments
 (0)