From 11ded2fe8fabf4392633fcdb3713a49e084746a1 Mon Sep 17 00:00:00 2001 From: wout Date: Mon, 22 Apr 2013 09:57:25 +0100 Subject: Added the rbox() method, bumped to v0.14 --- spec/spec/element.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'spec') diff --git a/spec/spec/element.js b/spec/spec/element.js index 167c0b9..e5db9b7 100644 --- a/spec/spec/element.js +++ b/spec/spec/element.js @@ -192,6 +192,45 @@ describe('Element', function() { var box = rect.bbox() expect(box.x).toBe(2) expect(box.y).toBe(12) + expect(box.cx).toBe(54.5) + expect(box.cy).toBe(117) + expect(box.width).toBe(105) + expect(box.height).toBe(210) + }) + it('should return the correct bounding within a viewbox', function() { + var rect = draw.size(300,200).viewbox(150,100).rect(105,210).move(2,12) + var box = rect.bbox() + expect(box.x).toBe(2) + expect(box.y).toBe(12) + expect(box.cx).toBe(54.5) + expect(box.cy).toBe(117) + expect(box.width).toBe(105) + expect(box.height).toBe(210) + }) + }) + + describe('rbox()', function() { + it('should return an instance of SVG.RBox', function() { + var rect = draw.rect(100,100) + expect(rect.rbox() instanceof SVG.RBox).toBe(true) + }) + it('should return the correct rectangular box', function() { + var rect = draw.size(200,150).viewbox(0,0,200,150).rect(105,210).move(2,12) + var box = rect.rbox() + expect(box.x).toBe(2) + expect(box.y).toBe(12) + expect(box.cx).toBe(54.5) + expect(box.cy).toBe(117) + expect(box.width).toBe(105) + expect(box.height).toBe(210) + }) + it('should return the correct rectangular box within a viewbox', function() { + var rect = draw.size(200,150).viewbox(0,0,100,75).rect(105,210).move(2,12) + var box = rect.rbox() + expect(box.x).toBe(2) + expect(box.y).toBe(12) + expect(box.cx).toBe(54.5) + expect(box.cy).toBe(117) expect(box.width).toBe(105) expect(box.height).toBe(210) }) -- cgit v1.2.3