From b48f03348ba04fb875c193f7e630fb35601bd9fe Mon Sep 17 00:00:00 2001 From: wout Date: Sat, 25 Jan 2014 14:34:03 +0100 Subject: Added addTo() and putIn() methods, added more detailed documentation --- spec/spec/element.js | 20 ++++++++++++++++++++ spec/spec/hyperlink.js | 22 ++++++++++++++++++++++ 2 files changed, 42 insertions(+) (limited to 'spec') diff --git a/spec/spec/element.js b/spec/spec/element.js index acb5de5..f1edb01 100644 --- a/spec/spec/element.js +++ b/spec/spec/element.js @@ -192,6 +192,26 @@ describe('Element', function() { expect(draw.has(rect)).toBe(false) }) }) + + describe('addTo()', function() { + it('adds an element to a given parent and returns itself', function() { + var rect = draw.rect(100,100) + , group = draw.group() + + expect(rect.addTo(group)).toBe(rect) + expect(rect.parent).toBe(group) + }) + }) + + describe('putIn()', function() { + it('adds an element to a given parent and returns parent', function() { + var rect = draw.rect(100,100) + , group = draw.group() + + expect(rect.putIn(group)).toBe(group) + expect(rect.parent).toBe(group) + }) + }) describe('rbox()', function() { it('returns an instance of SVG.RBox', function() { diff --git a/spec/spec/hyperlink.js b/spec/spec/hyperlink.js index 1449f76..3fe78f8 100644 --- a/spec/spec/hyperlink.js +++ b/spec/spec/hyperlink.js @@ -36,4 +36,26 @@ describe('Hyperlink', function() { }) }) + describe('SVG.Element', function() { + var element + + beforeEach(function() { + element = draw.rect(100,100) + }) + + describe('linkTo()', function() { + it('wraps the called element in a link with given url', function() { + element.linkTo(url) + expect(element.parent.attr('href')).toBe(url) + }) + it('wraps the called element in a link with given block', function() { + element.linkTo(function(link) { + link.to(url).target('_blank') + }) + expect(element.parent.attr('href')).toBe(url) + expect(element.parent.attr('target')).toBe('_blank') + }) + }) + }) + }) \ No newline at end of file -- cgit v1.2.3