aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorPhilippe Bernard <philippe.bernard@gmail.com>2020-10-14 11:43:26 +0200
committerPhilippe Bernard <philippe.bernard@gmail.com>2020-10-14 11:43:26 +0200
commitd8ba15323a1336292a8faf5294c478bc1a69b646 (patch)
treea519ba910a4ecc516031a6c5f564e0e9197da52a /spec
parentc24eab6180fd86b2b5973d37d9a0099e1f50afbb (diff)
downloadsvg.js-d8ba15323a1336292a8faf5294c478bc1a69b646.tar.gz
svg.js-d8ba15323a1336292a8faf5294c478bc1a69b646.zip
Test case for Dom.clone() with assignNewIds = false
Diffstat (limited to 'spec')
-rw-r--r--spec/spec/elements/Dom.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/spec/spec/elements/Dom.js b/spec/spec/elements/Dom.js
index deb665a..c03eaec 100644
--- a/spec/spec/elements/Dom.js
+++ b/spec/spec/elements/Dom.js
@@ -165,7 +165,7 @@ describe('Dom.js', function () {
expect(clone.children()).toEqual([])
})
- it('assigns a new id to the element and to child elements', () => {
+ it('assigns a new id to the element and to child elements by default', () => {
const group = new G().id('group')
const rect = group.rect(100, 100).id('rect')
const clone = group.clone()
@@ -173,6 +173,14 @@ describe('Dom.js', function () {
expect(clone.id()).not.toBe(group.id())
})
+ it('does not assign a new id to the element and to child elements', () => {
+ const group = new G().id('group')
+ const rect = group.rect(100, 100).id('rect')
+ const clone = group.clone(true, false)
+ expect(clone.get(0).id()).toBe(rect.id())
+ expect(clone.id()).toBe(group.id())
+ })
+
it('returns an instance of the same class the method was called on', () => {
const rect = new Dom(create('rect'))
expect(rect.constructor).toBe(Dom)