From 559fcf25cd9cb9e964b96cceafb9a31c8c20c458 Mon Sep 17 00:00:00 2001 From: Simon <34153549+seIncorp@users.noreply.github.com> Date: Tue, 31 Jul 2018 08:21:59 +0200 Subject: [PATCH 1/3] New test case for 'fromArray' function --- .../linked-list/__test__/LinkedList.test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/data-structures/linked-list/__test__/LinkedList.test.js b/src/data-structures/linked-list/__test__/LinkedList.test.js index 384e44fa5b..2488017db6 100644 --- a/src/data-structures/linked-list/__test__/LinkedList.test.js +++ b/src/data-structures/linked-list/__test__/LinkedList.test.js @@ -31,6 +31,20 @@ describe('LinkedList', () => { expect(linkedList.toString()).toBe('3,2,1'); }); + it('should get nodes from other Linked list', () => { + const linkedList1 = new LinkedList(); + linkedList.append(1); + linkedList.append(2); + linkedList.append(3); + linkedList.append(4); + linkedList.append(5); + const array = linkedList1.toArray(); + + const linkedList2 = new LinkedList(); + linkedList2.fromArray(array); + expect(linkedList2.toString()).toBe('1,2,3,4,5'); + }); + it('should delete node by value from linked list', () => { const linkedList = new LinkedList(); From 9956b8db1cc743c4913b26d64a86d794020df7bd Mon Sep 17 00:00:00 2001 From: Simon <34153549+seIncorp@users.noreply.github.com> Date: Tue, 31 Jul 2018 08:24:55 +0200 Subject: [PATCH 2/3] Update LinkedList.test.js --- .../linked-list/__test__/LinkedList.test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/data-structures/linked-list/__test__/LinkedList.test.js b/src/data-structures/linked-list/__test__/LinkedList.test.js index 2488017db6..834c25ae1d 100644 --- a/src/data-structures/linked-list/__test__/LinkedList.test.js +++ b/src/data-structures/linked-list/__test__/LinkedList.test.js @@ -33,11 +33,11 @@ describe('LinkedList', () => { it('should get nodes from other Linked list', () => { const linkedList1 = new LinkedList(); - linkedList.append(1); - linkedList.append(2); - linkedList.append(3); - linkedList.append(4); - linkedList.append(5); + linkedList1.append(1); + linkedList1.append(2); + linkedList1.append(3); + linkedList1.append(4); + linkedList1.append(5); const array = linkedList1.toArray(); const linkedList2 = new LinkedList(); From 18991732e5bf85546e56a1628cd0df67f8842b5a Mon Sep 17 00:00:00 2001 From: Simon <34153549+seIncorp@users.noreply.github.com> Date: Tue, 31 Jul 2018 08:28:22 +0200 Subject: [PATCH 3/3] Update LinkedList.test.js Removing spaces in line 42 --- src/data-structures/linked-list/__test__/LinkedList.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data-structures/linked-list/__test__/LinkedList.test.js b/src/data-structures/linked-list/__test__/LinkedList.test.js index 834c25ae1d..0fa1313890 100644 --- a/src/data-structures/linked-list/__test__/LinkedList.test.js +++ b/src/data-structures/linked-list/__test__/LinkedList.test.js @@ -39,7 +39,7 @@ describe('LinkedList', () => { linkedList1.append(4); linkedList1.append(5); const array = linkedList1.toArray(); - + const linkedList2 = new LinkedList(); linkedList2.fromArray(array); expect(linkedList2.toString()).toBe('1,2,3,4,5');