]> source.dussan.org Git - svg.js.git/commitdiff
Test case for Dom.clone() with assignNewIds = false
authorPhilippe Bernard <philippe.bernard@gmail.com>
Wed, 14 Oct 2020 09:43:26 +0000 (11:43 +0200)
committerPhilippe Bernard <philippe.bernard@gmail.com>
Wed, 14 Oct 2020 09:43:26 +0000 (11:43 +0200)
spec/spec/elements/Dom.js

index deb665ad1c61f52440b392e578914ff0ded74756..c03eaec25e0d8be4d9269a5f20328590efc7771c 100644 (file)
@@ -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)