diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2017-02-20 15:29:14 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2017-02-20 15:29:14 +0100 |
commit | 1144404e4bea677c293e9bad273ce273aa1cd885 (patch) | |
tree | ec66756c26c653194619a055dffa0234811b55fe /spec | |
parent | dfc07aa5be10a2b3749c3aae548d3652f0b780d5 (diff) | |
download | svg.js-1144404e4bea677c293e9bad273ce273aa1cd885.tar.gz svg.js-1144404e4bea677c293e9bad273ce273aa1cd885.zip |
Added clone method to SVG.Array/PointArray/PathArray (#590)
Diffstat (limited to 'spec')
-rw-r--r-- | spec/spec/array.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/spec/array.js b/spec/spec/array.js index 2e57d38..f1d264a 100644 --- a/spec/spec/array.js +++ b/spec/spec/array.js @@ -19,6 +19,46 @@ describe('Array', function () { expect(array.reverse()).toBe(array) }) }) + describe('clone()', function() { + it('creates a deep clone of the array', function() { + array = new SVG.Array([1, 2, 3, 4, 5]) + + clone = array.clone() + + expect(array).toEqual(clone) + expect(array).not.toBe(clone) + + array = new SVG.Array([[1,2], [3, 4], [5]]) + clone = array.clone() + + expect(array).toEqual(array) + for(var i = 0, len = array.value.length; i; ++i){ + expect(array[i]).not.toBe(clone[i]) + } + }) + it('also works with PointArray', function() { + array = new SVG.PointArray([1,2,3,4,5,6]) + clone = array.clone() + + expect(array).toEqual(clone) + expect(array).not.toBe(clone) + + for(var i = 0, len = array.value.length; i; ++i){ + expect(array[i]).not.toBe(clone[i]) + } + }) + it('also works with PathArray', function() { + array = new SVG.PathArray([['M',1,2],['L',3,4],['L',5,6]]) + clone = array.clone() + + expect(array).toEqual(clone) + expect(array).not.toBe(clone) + + for(var i = 0, len = array.value.length; i; ++i){ + expect(array[i]).not.toBe(clone[i]) + } + }) + }) }) |