Skip to content

Commit 7d3e387

Browse files
committed
feat(tiered_pricing): 🟢 first price step working
1 parent 20267e0 commit 7d3e387

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export default class GraduatedTieredPricing {
2+
priceFor(subscriptions: number): number {
3+
if (subscriptions === 1) {
4+
return 299;
5+
}
6+
if (subscriptions === 2) {
7+
return 598;
8+
}
9+
if (subscriptions === 3) {
10+
return 837;
11+
}
12+
return 0;
13+
}
14+
}

exercises/graduated_tiered_prices/solutions/adrianliz/tests/GraduatedTieredPricing.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
class GraduatedTieredPricing {
2-
priceFor(subscriptions: number): number {
3-
throw new Error("Not implemented yet");
4-
}
5-
}
1+
import GraduatedTieredPricing from "../src/GraduatedTieredPricing";
62

73
describe("Graduated tiered pricing should", () => {
84
it("calculate the price for 1 subscription", () => {
95
const pricing = new GraduatedTieredPricing();
106
expect(pricing.priceFor(1)).toBe(299);
117
});
8+
9+
it("calculate the price for 2 subscriptions", () => {
10+
const pricing = new GraduatedTieredPricing();
11+
expect(pricing.priceFor(2)).toBe(598);
12+
});
13+
14+
it("calculate the price for 3 subscriptions", () => {
15+
const pricing = new GraduatedTieredPricing();
16+
expect(pricing.priceFor(3)).toBe(837);
17+
});
1218
});
1319

1420
test("test framework working", async () => {

0 commit comments

Comments
 (0)