11import each from "jest-each" ;
22
3+ import GraduatedTier from "../src/GraduatedTier" ;
34import GraduatedTieredPricing from "../src/GraduatedTieredPricing" ;
45import NumberOfSubscriptionsNotAllowed from "../src/NumberOfSubscriptionsNotAllowed" ;
56import Subscriptions from "../src/Subscriptions" ;
67
78describe ( "Graduated tiered pricing should" , ( ) => {
9+ const defaultTiers = ( ) : GraduatedTier [ ] => {
10+ return [
11+ new GraduatedTier ( 1 , 2 , 299 ) ,
12+ new GraduatedTier ( 3 , 10 , 239 ) ,
13+ new GraduatedTier ( 11 , 25 , 219 ) ,
14+ new GraduatedTier ( 26 , 50 , 199 ) ,
15+ new GraduatedTier ( 51 , Number . MAX_SAFE_INTEGER , 149 ) ,
16+ ] ;
17+ } ;
18+
819 it ( "throw number of subscriptions not allowed for 0 subscriptions" , ( ) => {
9- const pricing = new GraduatedTieredPricing ( null ) ;
20+ const tiers = defaultTiers ( ) ;
21+ const pricing = new GraduatedTieredPricing ( tiers ) ;
1022 expect ( ( ) => pricing . priceFor ( new Subscriptions ( 0 ) ) ) . toThrow (
1123 NumberOfSubscriptionsNotAllowed
1224 ) ;
@@ -23,7 +35,8 @@ describe("Graduated tiered pricing should", () => {
2335 ] ) . it (
2436 "calculate the price for %i subscriptions" ,
2537 ( subscriptions : number , expectedPrice : number ) => {
26- const pricing = new GraduatedTieredPricing ( null ) ;
38+ const tiers = defaultTiers ( ) ;
39+ const pricing = new GraduatedTieredPricing ( tiers ) ;
2740 expect ( pricing . priceFor ( new Subscriptions ( subscriptions ) ) ) . toBe (
2841 expectedPrice
2942 ) ;
0 commit comments