summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/06-test-grouper.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/06-test-grouper.js b/test/06-test-grouper.js
index 41ed0b0..5388875 100644
--- a/test/06-test-grouper.js
+++ b/test/06-test-grouper.js
@@ -29,6 +29,9 @@ var east = new Rect( new vec(2,6), new vec(1,5) )
var corner = new Rect( new vec(3,7), new vec(3,7) )
var peninsula = new Rect( new vec(4,6), new vec(6,8) )
+var big_rect = new Rect( new vec(1,5), new vec(1,5) )
+var hall_rect = new Rect( new vec(3,4), new vec(4,8) )
+
var rect_room = new Room({ id: "rect", rect: rect, height: 2 })
var east_room = new Room({ id: "east", rect: east, height: 2 })
var corner_room = new Room({ id: "corner", rect: corner, height: 2 })
@@ -38,6 +41,9 @@ var peninsula_shorter = new Room({ id: "peninsula", rect: peninsula, height: 1 }
var taller_room = new Room({ id: "taller", rect: rect, height: 3 })
+var big_room = new Room({ id: "big_room", rect: big_rect, height: 4 })
+var hallway = new Room({ id: "hallway", rect: hall_rect, height: 2 })
+
function report(a) {
console.log( a.join("\n") )
}
@@ -230,6 +236,7 @@ describe('grouper(rect,corner,peninsula_taller)', function(){
})
it("right has 5 walls", function(){
assert.equal(5, right_walls.length)
+ // console.log(right_walls.map(function(m){ return m.vec + " " + m.edge + " " + m.faces+"" }))
})
it("front has 3 walls", function(){
assert.equal(3, front_walls.length)
@@ -240,3 +247,42 @@ describe('grouper(rect,corner,peninsula_taller)', function(){
})
})
+describe('grouper(room,hallway)', function(){
+ reset()
+ Rooms.add( big_room )
+ Rooms.add( hallway )
+ rebuild()
+
+ var collections = Rooms.grouper.collect()
+
+ describe('#collect(room,hallway)', function(){
+ it("should find an appropriate number of wall segments", function(){
+ assert.equal(3, collections[FRONT].length)
+ assert.equal(4, collections[BACK].length)
+ assert.equal(3, collections[LEFT].length)
+ assert.equal(3, collections[RIGHT].length)
+ })
+ })
+
+ describe('#group(rect,corner,peninsula_taller)', function(){
+ var front_walls = Rooms.grouper.group([], collections, FRONT)
+ var back_walls = Rooms.grouper.group([], collections, BACK)
+ var left_walls = Rooms.grouper.group([], collections, LEFT)
+ var right_walls = Rooms.grouper.group([], collections, RIGHT)
+
+ it("left has 2 walls", function(){
+ assert.equal(2, left_walls.length)
+ })
+ it("right has 2 walls", function(){
+ assert.equal(2, right_walls.length)
+ })
+ it("front has 1 wall", function(){
+ assert.equal(1, front_walls.length)
+ })
+ it("back has 2 walls", function(){
+ assert.equal(2, back_walls.length)
+ // console.log(back_walls.map(function(m){ return m.vec + " " + m.edge + " " + m.faces+"" }))
+ })
+ })
+})
+