diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/spec/container.js | 27 | ||||
-rw-r--r-- | spec/spec/set.js | 11 |
2 files changed, 38 insertions, 0 deletions
diff --git a/spec/spec/container.js b/spec/spec/container.js index 47a871e..02bc4e9 100644 --- a/spec/spec/container.js +++ b/spec/spec/container.js @@ -287,7 +287,34 @@ describe('Container', function() { expect(draw.get(3)).toBe(undefined) }) }) + + describe('has()', function() { + it('determines if a given element is a child of the parent', function() { + var rect = draw.rect(100,100) + var circle = draw.circle(100) + var group = draw.group() + var line = group.line(0,0,100,100) + expect(draw.has(rect)).toBe(true) + expect(draw.has(circle)).toBe(true) + expect(draw.has(group)).toBe(true) + expect(draw.has(line)).toBe(false) + expect(group.has(line)).toBe(true) + }) + }) + describe('index()', function() { + it('determines the index of given element', function() { + var rect = draw.rect(100,100) + var circle = draw.circle(100) + var group = draw.group() + var line = group.line(0,0,100,100) + expect(draw.index(rect)).toBe(0) + expect(draw.index(circle)).toBe(1) + expect(draw.index(group)).toBe(2) + expect(draw.index(line)).toBe(-1) + expect(group.index(line)).toBe(0) + }) + }) }) diff --git a/spec/spec/set.js b/spec/spec/set.js index b6199d7..0eb822d 100644 --- a/spec/spec/set.js +++ b/spec/spec/set.js @@ -88,6 +88,17 @@ describe('Set', function() { }) }) + describe('index()', function() { + it('returns the index of a given element within the set', function() { + set.add(e1).add(e2).add(e3).add(e5) + expect(set.index(e1)).toBe(0) + expect(set.index(e2)).toBe(1) + expect(set.index(e3)).toBe(2) + expect(set.index(e4)).toBe(-1) + expect(set.index(e5)).toBe(3) + }) + }) + describe('valueOf()', function() { it('returns the members array', function() { set.add(e1) |