-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Franc from '.'; | ||
|
||
describe('Franc', () => { | ||
describe('multiplication', () => { | ||
it('should multiply $5 by 2 and get $10', () => { | ||
const five = new Franc(5); | ||
const product = five.times(2); | ||
expect(product.equals(new Franc(10))).toBe(true); | ||
}); | ||
|
||
it('should preserve the initial dollar amount when multiplying multiple times', () => { | ||
const five = new Franc(5); | ||
let product: Franc = five.times(2); | ||
expect(product.equals(new Franc(10))).toBe(true); | ||
product = five.times(3); | ||
expect(product.equals(new Franc(15))).toBe(true); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export default class Franc { | ||
private amount: number; | ||
|
||
constructor(amount: number) { | ||
this.amount = amount; | ||
} | ||
|
||
times(multiplier: number): Franc { | ||
return new Franc(this.amount * multiplier); | ||
} | ||
|
||
equals(dollar: Object): boolean { | ||
return this.amount == (dollar as Franc).amount; | ||
} | ||
} |