Skip to content

Commit a42204a

Browse files
committed
Merge pull request #1 from CodingHouseFI/master
Allow users to change house dimensions
2 parents bb149d3 + cdc4ac6 commit a42204a

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

main.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
class 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-
// ----------
3732
import { expect } from "chai";
3833

3934
describe("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
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
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",

0 commit comments

Comments
 (0)