diff options
author | wout <wout@impinc.co.uk> | 2014-01-25 14:34:03 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-01-25 14:34:03 +0100 |
commit | b48f03348ba04fb875c193f7e630fb35601bd9fe (patch) | |
tree | 573a2a9ff6f3b839c151d89f86a095bb3c98a87a /spec | |
parent | 70879728a81c7bcee9f509a96b23443d35c912aa (diff) | |
download | svg.js-b48f03348ba04fb875c193f7e630fb35601bd9fe.tar.gz svg.js-b48f03348ba04fb875c193f7e630fb35601bd9fe.zip |
Added addTo() and putIn() methods, added more detailed documentation
Diffstat (limited to 'spec')
-rw-r--r-- | spec/spec/element.js | 20 | ||||
-rw-r--r-- | spec/spec/hyperlink.js | 22 |
2 files changed, 42 insertions, 0 deletions
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 |