Skip to content

Commit 7ac1660

Browse files
committed
feat(tiered_pricing): 🔴 should return price for any subscription
1 parent 878fb89 commit 7ac1660

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default class NumberOfSubscriptionsNotAllowed extends Error {
2+
constructor() {
3+
super("Number of subscriptions not allowed");
4+
}
5+
}

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import GraduatedTieredPricing from "../src/GraduatedTieredPricing";
2+
import NumberOfSubscriptionsNotAllowed from "../src/NumberOfSubscriptionsNotAllowed";
23

34
describe("Graduated tiered pricing should", () => {
5+
it("calculate the price for 0 subscriptions", () => {
6+
const pricing = new GraduatedTieredPricing();
7+
expect(pricing.priceFor(0)).toThrow(NumberOfSubscriptionsNotAllowed);
8+
});
9+
410
it("calculate the price for 1 subscription", () => {
511
const pricing = new GraduatedTieredPricing();
612
expect(pricing.priceFor(1)).toBe(299);
@@ -15,6 +21,26 @@ describe("Graduated tiered pricing should", () => {
1521
const pricing = new GraduatedTieredPricing();
1622
expect(pricing.priceFor(3)).toBe(837);
1723
});
24+
25+
it("calculate the price for 11 subscriptions", () => {
26+
const pricing = new GraduatedTieredPricing();
27+
expect(pricing.priceFor(11)).toBe(2990);
28+
});
29+
30+
it("calculate the price for 26 subscriptions", () => {
31+
const pricing = new GraduatedTieredPricing();
32+
expect(pricing.priceFor(26)).toBe(6294);
33+
});
34+
35+
it("calculate the price for 50 subscriptions", () => {
36+
const pricing = new GraduatedTieredPricing();
37+
expect(pricing.priceFor(50)).toBe(10950);
38+
});
39+
40+
it("calculate the price for 100 subscriptions", () => {
41+
const pricing = new GraduatedTieredPricing();
42+
expect(pricing.priceFor(100)).toBe(21900);
43+
});
1844
});
1945

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

0 commit comments

Comments
 (0)