File tree Expand file tree Collapse file tree 2 files changed +25
-5
lines changed
exercises/graduated_tiered_prices/solutions/adrianliz Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 1- class GraduatedTieredPricing {
2- priceFor ( subscriptions : number ) : number {
3- throw new Error ( "Not implemented yet" ) ;
4- }
5- }
1+ import GraduatedTieredPricing from "../src/GraduatedTieredPricing" ;
62
73describe ( "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
1420test ( "test framework working" , async ( ) => {
You can’t perform that action at this time.
0 commit comments