Skip to content

Commit

Permalink
update add tests for currency identity when fetching rate
Browse files Browse the repository at this point in the history
Task list:
- $5 + 10CHF = $10 if rate is 2:1 🎯
- $5 + $5 = $10 βœ…
- Return Money from $5 + $5
- Bank.reduce(Money) βœ…
- Reduce Money with conversion βœ…
- Reduce(Bank, String) βœ…
  • Loading branch information
kaiosilveira committed Sep 29, 2022
1 parent d9b776f commit b95f324
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/bank/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import Expression, { Sum } from '../expression';
import Money from '../money';

describe('Bank', () => {
describe('rates', () => {
it('should return 1 if currencies are the same', () => {
const bank: Bank = new Bank();
expect(bank.rate('USD', 'USD')).toEqual(1);
});
});

describe('reduce', () => {
describe('sum', () => {
it('should reduce a sum expression', () => {
Expand All @@ -22,6 +29,7 @@ describe('Bank', () => {

it('should reduce mixed Money currencies', () => {
const bank: Bank = new Bank();
bank.addRate('CHF', 'USD', 2);
const result: Money = bank.reduce(Money.franc(2), 'USD');
expect(result).toEqual(Money.dollar(1));
});
Expand Down

0 comments on commit b95f324

Please sign in to comment.