From: Morgan Harris Date: Wed, 24 Nov 2021 00:47:42 +0000 (+1100) Subject: Add a test to check that the new and original methods both work X-Git-Tag: 3.2.1~4^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=bb8b54a3bbe415f1ca6c9fbe917604adb16b53ad;p=svg.js.git Add a test to check that the new and original methods both work --- diff --git a/spec/spec/types/List.js b/spec/spec/types/List.js index 9fd27db..21f9cb2 100644 --- a/spec/spec/types/List.js +++ b/spec/spec/types/List.js @@ -82,6 +82,21 @@ describe('List.js', () => { List.extend([ 'unshift' ]) expect(new List().unshift).toEqual(any(Function)) expect(new List().$unshift).toEqual(Array.prototype.unshift) + + // Check that it works! + const sourceArray = [ + { 'unshift': () => 1 }, + { 'unshift': () => 2 }, + { 'unshift': () => 3 } + ]; + const list = new List(sourceArray) + + expect(list).toEqual(sourceArray) + expect(list.unshift(0)).toEqual([1,2,3]) + + expect(list.$unshift(0)).toEqual(4) + expect(list).toEqual([0].concat(sourceArray)) + delete List.prototype.unshift; });