aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2014-06-21 22:04:12 +0200
committerwout <wout@impinc.co.uk>2014-06-21 22:04:12 +0200
commit1953dbcdb44c6ae94e18501e8c1168e8fb8d71d8 (patch)
treedf59a0db9cc0156ba64ebbc08f3cb5b670f71153 /spec
parent0bb294ad9189797014b1e1bf55e41ca4b1ead19e (diff)
downloadsvg.js-1953dbcdb44c6ae94e18501e8c1168e8fb8d71d8.tar.gz
svg.js-1953dbcdb44c6ae94e18501e8c1168e8fb8d71d8.zip
Documented and added specs for new selector method
Diffstat (limited to 'spec')
-rw-r--r--spec/spec/selector.js31
-rwxr-xr-xspec/spec/set.js6
2 files changed, 37 insertions, 0 deletions
diff --git a/spec/spec/selector.js b/spec/spec/selector.js
index 4727bfd..8c16aa1 100644
--- a/spec/spec/selector.js
+++ b/spec/spec/selector.js
@@ -23,5 +23,36 @@ describe('Selector', function() {
expect(SVG.get(path.attr('marker-end'))).toBe(mark)
})
})
+
+ describe('select()', function() {
+ var e1, e2, e3, e4 ,e5
+
+ beforeEach(function() {
+ e1 = draw.rect(100, 100).addClass('selectable-element')
+ e2 = draw.rect(100, 100).addClass('unselectable-element')
+ e3 = draw.rect(100, 100).addClass('selectable-element')
+ e4 = draw.rect(100, 100).addClass('unselectable-element')
+ e5 = draw.rect(100, 100).addClass('selectable-element')
+ })
+ it('gets all elements with a given class name', function() {
+ expect(SVG.select('rect.selectable-element').valueOf()).toEqual([e1, e3, e5])
+ })
+ it('returns an instance of SVG.Set', function() {
+ expect(SVG.select('rect.selectable-element') instanceof SVG.Set).toBe(true)
+ })
+ })
+
+ describe('Parent#select()', function() {
+ it('gets all elements with a given class name inside a given element', function() {
+ var group = draw.group()
+ , e1 = draw.rect(100, 100).addClass('selectable-element')
+ , e2 = draw.rect(100, 100).addClass('unselectable-element')
+ , e3 = group.rect(100, 100).addClass('selectable-element')
+ , e4 = draw.rect(100, 100).addClass('unselectable-element')
+ , e5 = group.rect(100, 100).addClass('selectable-element')
+
+ expect(group.select('rect.selectable-element').valueOf()).toEqual([e3, e5])
+ })
+ })
}) \ No newline at end of file
diff --git a/spec/spec/set.js b/spec/spec/set.js
index 1238ee7..02ff2bb 100755
--- a/spec/spec/set.js
+++ b/spec/spec/set.js
@@ -19,6 +19,12 @@ describe('Set', function() {
expect(draw.set() instanceof SVG.Set).toBeTruthy()
})
+ it('creates a set with initial value', function() {
+ var members = [1, 2, 4]
+
+ expect(draw.set(members).valueOf()).toBe(members)
+ })
+
describe('add()', function() {
it('returns the set instance', function() {
expect(set.add(e1)).toBe(set)