Skip to content

Commit ef99bc8

Browse files
committed
[js][bonus-01_base] Calculate user daily bonus
1 parent 16dcb23 commit ef99bc8

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export class DailyBonusPointsCalculator {
2+
POINTS_PER_DAY = 10;
3+
4+
calculate(consecutiveDays) {
5+
return consecutiveDays * this.POINTS_PER_DAY;
6+
}
7+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {DailyBonusPointsCalculator} from "../src/DailyBonusPointsCalculator";
2+
3+
describe('DailyBonusPointsCalculator should', () => {
4+
it('Calculate points for a user on its first day', () => {
5+
const calculator = new DailyBonusPointsCalculator();
6+
7+
expect(calculator.calculate(1)).toBe(10);
8+
});
9+
10+
it('Calculate points for a user on its second consecutive week', () => {
11+
const calculator = new DailyBonusPointsCalculator();
12+
13+
expect(calculator.calculate(14)).toBe(140);
14+
});
15+
});

0 commit comments

Comments
 (0)