File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
src/functions-into-class-hierarchy/bird Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,11 @@ export class EuropeanSwallow extends Bird {
3636 }
3737}
3838
39- export class AfricanSwallow extends Bird { }
39+ export class AfricanSwallow extends Bird {
40+ get plumage ( ) {
41+ return this . numberOfCoconuts > 2 ? 'tired' : 'average' ;
42+ }
43+ }
4044
4145export class NorwegianBlueParrot extends Bird { }
4246
Original file line number Diff line number Diff line change @@ -80,6 +80,20 @@ describe('EuropeanSwallow', () => {
8080 } ) ;
8181} ) ;
8282
83+ describe ( 'AfricanSwallow' , ( ) => {
84+ describe ( 'plumage' , ( ) => {
85+ it ( 'should return "tired" for more than 2 coconuts' , ( ) => {
86+ const bird = new AfricanSwallow ( { type : 'AfricanSwallow' , numberOfCoconuts : 3 } ) ;
87+ expect ( bird . plumage ) . toBe ( 'tired' ) ;
88+ } ) ;
89+
90+ it ( 'should return "average" for 2 or less coconuts' , ( ) => {
91+ const bird = new AfricanSwallow ( { type : 'AfricanSwallow' , numberOfCoconuts : 2 } ) ;
92+ expect ( bird . plumage ) . toBe ( 'average' ) ;
93+ } ) ;
94+ } ) ;
95+ } ) ;
96+
8397describe ( 'createBird' , ( ) => {
8498 it ( 'should return an instance of EuropeanSwallow for type EuropeanSwallow' , ( ) => {
8599 const bird = { type : 'EuropeanSwallow' } ;
You can’t perform that action at this time.
0 commit comments