diff options
author | Morgan Harris <gormster@me.com> | 2021-11-23 13:11:12 +1100 |
---|---|---|
committer | Morgan Harris <gormster@me.com> | 2021-11-23 13:11:12 +1100 |
commit | 180b292968f7b1491757ea9195cb12bf6c12bba9 (patch) | |
tree | 10906ac72e1e653b65d30f24e0f52a122f3b94b3 /spec | |
parent | ed0989b26ea7c5954d1ebeac89960bc9ec49aedf (diff) | |
download | svg.js-180b292968f7b1491757ea9195cb12bf6c12bba9.tar.gz svg.js-180b292968f7b1491757ea9195cb12bf6c12bba9.zip |
Add test for closest matching parent
Diffstat (limited to 'spec')
-rw-r--r-- | spec/spec/elements/Element.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/spec/elements/Element.js b/spec/spec/elements/Element.js index 0d7fa55..5076373 100644 --- a/spec/spec/elements/Element.js +++ b/spec/spec/elements/Element.js @@ -175,6 +175,19 @@ describe('Element.js', function () { expect(rect.parents(group1).length).toBe(3) expect(rect.parents()).toEqual([ group3, group2, group1, canvas ]) }) + + it('returns array of parents until the closest matching parent', () => { + const canvas = SVG().addTo(container) + const groupA = canvas.group().addClass('test') + const group1 = canvas.group().addClass('test') + const group2 = group1.group().addClass('test').addClass('foo') + const group3 = group2.group().addClass('foo') + const rect = group3.rect(100, 100) + + expect(rect.parents('.test')).toEqual([ group3, group2 ]) + expect(rect.parents('.foo')).toEqual([ group3 ]) + expect(rect.parents('.test:not(.foo)')).toEqual([ group3, group2, group1 ]) + }) }) describe('reference()', () => { |