diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/spec/selector.js | 31 | ||||
-rwxr-xr-x | spec/spec/set.js | 6 |
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) |