Skip to content

Commit

Permalink
✨ 【TODO】 「他のオブジェクトとの等価性比較」のテストを追加
Browse files Browse the repository at this point in the history
・言語的には問題がなかったがテストを追加
  • Loading branch information
dodonki1223 committed Jan 9, 2022
1 parent 35376db commit 0d8d1bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- [ ] $5 + $5がMoneyを返す
- [ ] Money の丸め処理どうする?
- [ ] 他のオブジェクトとの等価性比較

- [x] 他のオブジェクトとの等価性比較
- [x] 5CHF * 2 = 10CHF
- [x] Sum.plus
- [x] Expression.times
Expand Down
8 changes: 8 additions & 0 deletions src/__tests__/money.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ test('null equals', () => {
expect(dollarFive.equals(null)).toBeFalsy();
});

test('other object equals', () => {
const other = {hoge: 1} as unknown as Money;
expect(Money.dollar(5).equals(other)).toBeFalsy();

// NOTE: TypeScript は undefined === 5 はエラーにならずに通ってしまう
expect(undefined === 5).toBeFalsy();
});

test('equals Franc = Dollar', () => {
expect(Money.franc(5).equals(Money.dollar(5))).toBeTruthy();
expect(Money.franc(5).equals(Money.dollar(6))).toBeFalsy();
Expand Down

0 comments on commit 0d8d1bf

Please sign in to comment.