diff --git a/test/test-packer.js b/test/test-packer.js index 2704d38..fe9bd53 100644 --- a/test/test-packer.js +++ b/test/test-packer.js @@ -18,7 +18,7 @@ test( 'basics', function() { }); test( 'packing', function() { - var packr = new Packer( 3, 10 ); + var packr = new Packer( 30, 100 ); // 112 // 352 @@ -26,11 +26,11 @@ test( 'packing', function() { // xxx // xxx - var rect1 = new Rect({ width: 2, height: 1 }); - var rect2 = new Rect({ width: 1, height: 2 }); - var rect3 = new Rect({ width: 1, height: 2 }); - var rect4 = new Rect({ width: 2, height: 1 }); - var rect5 = new Rect({ width: 1, height: 1 }); + var rect1 = new Rect({ width: 20, height: 10 }); + var rect2 = new Rect({ width: 10, height: 20 }); + var rect3 = new Rect({ width: 10, height: 20 }); + var rect4 = new Rect({ width: 20, height: 10 }); + var rect5 = new Rect({ width: 10, height: 10 }); packr.pack( rect1 ); packr.pack( rect2 ); @@ -40,26 +40,26 @@ test( 'packing', function() { equal( rect1.x, 0, 'rect1.x top left' ); equal( rect1.y, 0, 'rect1.y top left' ); - equal( rect2.x, 2, 'rect2.x top right' ); + equal( rect2.x, 20, 'rect2.x top right' ); equal( rect2.y, 0, 'rect2.y top right' ); equal( rect3.x, 0, 'rect3.x bottom left' ); - equal( rect3.y, 1, 'rect3.y bottom left' ); - equal( rect4.x, 1, 'rect4.x bottom right' ); - equal( rect4.y, 2, 'rect4.y bottom right' ); - equal( rect5.x, 1, 'rect5.x packed in center' ); - equal( rect5.y, 1, 'rect5.y packed in center' ); + equal( rect3.y, 10, 'rect3.y bottom left' ); + equal( rect4.x, 10, 'rect4.x bottom right' ); + equal( rect4.y, 20, 'rect4.y bottom right' ); + equal( rect5.x, 10, 'rect5.x packed in center' ); + equal( rect5.y, 10, 'rect5.y packed in center' ); // bottom space is open equal( packr.spaces.length, 1, 'one space open' ); var space = packr.spaces[0]; - equal( space.width, 3, 'space.width' ); - equal( space.height, 7, 'space.height' ); + equal( space.width, 30, 'space.width' ); + equal( space.height, 70, 'space.height' ); equal( space.x, 0, 'space.x' ); - equal( space.y, 3, 'space.y' ); + equal( space.y, 30, 'space.y' ); }); test( 'packing with a placed', function() { - var packr = new Packer( 3, 10 ); + var packr = new Packer( 30, 100 ); // 225 // 311 @@ -69,15 +69,15 @@ test( 'packing with a placed', function() { // xxx var rect1 = new Rect({ - width: 2, - height: 1, - x: 1, - y: 1 + width: 20, + height: 10, + x: 10, + y: 10 }); - var rect2 = new Rect({ width: 2, height: 1 }); - var rect3 = new Rect({ width: 1, height: 2 }); - var rect4 = new Rect({ width: 1, height: 2 }); - var rect5 = new Rect({ width: 1, height: 1 }); + var rect2 = new Rect({ width: 20, height: 10 }); + var rect3 = new Rect({ width: 10, height: 20 }); + var rect4 = new Rect({ width: 10, height: 20 }); + var rect5 = new Rect({ width: 10, height: 10 }); packr.placed( rect1 ); packr.pack( rect2 ); @@ -88,10 +88,10 @@ test( 'packing with a placed', function() { equal( rect2.x, 0, 'rect2.x top left' ); equal( rect2.y, 0, 'rect2.y top left' ); equal( rect3.x, 0, 'rect3.x left side' ); - equal( rect3.y, 1, 'rect3.y left side' ); - equal( rect4.x, 1, 'rect4.x bottom center' ); - equal( rect4.y, 2, 'rect4.y bottom center' ); - equal( rect5.x, 2, 'rect5.x packed in top right' ); + equal( rect3.y, 10, 'rect3.y left side' ); + equal( rect4.x, 10, 'rect4.x bottom center' ); + equal( rect4.y, 20, 'rect4.y bottom center' ); + equal( rect5.x, 20, 'rect5.x packed in top right' ); equal( rect5.y, 0, 'rect5.y packed in top right' ); equal( packr.spaces.length, 3, '3 spaces left' ); @@ -105,17 +105,17 @@ test( 'packing horizontal', function() { equal( rect.y, y, 'y: ' + y ); } - var packr = new Packer( 10, 3, 'rightwardTopToBottom' ); + var packr = new Packer( 100, 30, 'rightwardTopToBottom' ); // 133xx // 154xx // 224xx - var rect1 = new Rect({ width: 1, height: 2 }); - var rect2 = new Rect({ width: 2, height: 1 }); - var rect3 = new Rect({ width: 2, height: 1 }); - var rect4 = new Rect({ width: 1, height: 2 }); - var rect5 = new Rect({ width: 1, height: 1 }); + var rect1 = new Rect({ width: 10, height: 20 }); + var rect2 = new Rect({ width: 20, height: 10 }); + var rect3 = new Rect({ width: 20, height: 10 }); + var rect4 = new Rect({ width: 10, height: 20 }); + var rect5 = new Rect({ width: 10, height: 10 }); packr.pack( rect1 ); packr.pack( rect2 ); @@ -124,17 +124,17 @@ test( 'packing horizontal', function() { packr.pack( rect5 ); checkRect( rect1, 0, 0 ); - checkRect( rect2, 0, 2 ); - checkRect( rect3, 1, 0 ); - checkRect( rect4, 2, 1 ); - checkRect( rect5, 1, 1 ); + checkRect( rect2, 0, 20 ); + checkRect( rect3, 10, 0 ); + checkRect( rect4, 20, 10 ); + checkRect( rect5, 10, 10 ); // bottom space is open equal( packr.spaces.length, 1, 'one space open' ); var space = packr.spaces[0]; - equal( space.width, 7, 'space.width' ); - equal( space.height, 3, 'space.height' ); - checkRect( space, 3, 0 ); + equal( space.width, 70, 'space.width' ); + equal( space.height, 30, 'space.height' ); + checkRect( space, 30, 0 ); });