File tree Expand file tree Collapse file tree 2 files changed +3
-10
lines changed
Expand file tree Collapse file tree 2 files changed +3
-10
lines changed Original file line number Diff line number Diff line change 11class House {
2-
32 constructor ( nameString ) {
43 // super(nameString);
54 this . name = nameString ;
65 this . rooms = [ ] ;
76 }
87 addRoom ( room ) {
98 this . rooms . push ( room ) ;
9+ return this ;
1010 }
1111 area ( ) {
1212 return this . rooms . reduce ( ( acc , e ) => {
1313 return acc + e . area ( ) ;
1414 } , 0 ) ;
1515 }
16-
1716}
1817
1918
@@ -25,15 +24,11 @@ class Room {
2524 this . length = length ;
2625 this . width = width ;
2726 }
28-
2927 area ( ) {
3028 return this . length * this . width ;
3129 }
3230}
3331
34- // ----------
35- // Tests
36- // ----------
3732import { expect } from "chai" ;
3833
3934describe ( "House" , ( ) => {
@@ -50,7 +45,6 @@ describe("House", () => {
5045 expect ( house2 . name ) . to . equal ( "Windmill Dr" ) ;
5146 } ) ;
5247
53-
5448 describe ( "Room" , ( ) => {
5549 it ( "throws an error if I try to define a room without properties" , ( ) => {
5650 expect ( ( ) => { new Room } ) . to . throw ( "Missing params" ) ;
@@ -71,7 +65,7 @@ describe("House", () => {
7165 let house1 , house2 ;
7266 beforeEach ( ( ) => {
7367 house1 = new House ( "Red" ) ;
74- house2 = new House ( "Yello " ) ;
68+ house2 = new House ( "Yellow " ) ;
7569
7670 let room1 = new Room ( { width : 7 , length : 8 } ) ;
7771 let room2 = new Room ( { width : 5 , length : 15 } ) ;
@@ -94,5 +88,4 @@ describe("House", () => {
9488 } ) ;
9589 } ) ;
9690
97-
9891} ) ;
Original file line number Diff line number Diff line change 44 "description" : " " ,
55 "main" : " main.js" ,
66 "scripts" : {
7- "test" : " mocha --compilers js:babel/register"
7+ "test" : " mocha --compilers js:babel/register main.js "
88 },
99 "author" : " " ,
1010 "license" : " ISC" ,
You can’t perform that action at this time.
0 commit comments