From e0be375fc57930306999f15c7a7266edb0ba3432 Mon Sep 17 00:00:00 2001 From: Morgan Harris Date: Tue, 23 Nov 2021 13:12:44 +1100 Subject: Return null if `until` not in parent chain --- spec/spec/elements/Element.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'spec') diff --git a/spec/spec/elements/Element.js b/spec/spec/elements/Element.js index 5076373..38b862f 100644 --- a/spec/spec/elements/Element.js +++ b/spec/spec/elements/Element.js @@ -188,6 +188,20 @@ describe('Element.js', function () { expect(rect.parents('.foo')).toEqual([ group3 ]) expect(rect.parents('.test:not(.foo)')).toEqual([ group3, group2, group1 ]) }) + + it('returns null if the passed element is not an ancestor', () => { + const canvas = SVG().addTo(container) + const groupA = canvas.group().addClass('test') + const group1 = canvas.group() + const group2 = group1.group() + const group3 = group2.group() + const rect = group3.rect(100, 100) + + + expect(rect.parents('.does-not-exist')).toEqual(null) + expect(rect.parents('.test')).toEqual(null) + expect(rect.parents(groupA)).toEqual(null) + }) }) describe('reference()', () => { -- cgit v1.2.3