From 9caf9ebaaa0756bd1e6a1a9eb7225bbf08819958 Mon Sep 17 00:00:00 2001 From: JD Medina Date: Thu, 2 Jan 2020 12:10:03 -0500 Subject: [PATCH 1/2] Update LinkedList.test.js Add a test to the LinkedList structure to test the toArray() method --- .../linked-list/__test__/LinkedList.test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/data-structures/linked-list/__test__/LinkedList.test.js b/src/data-structures/linked-list/__test__/LinkedList.test.js index 3a4241c9..d8f5e184 100644 --- a/src/data-structures/linked-list/__test__/LinkedList.test.js +++ b/src/data-structures/linked-list/__test__/LinkedList.test.js @@ -1,4 +1,5 @@ import LinkedList from '../LinkedList'; +import LinkedListNode from '../LinkedListNode'; describe('LinkedList', () => { it('should create empty linked list', () => { @@ -192,6 +193,23 @@ describe('LinkedList', () => { expect(linkedList.toString()).toBe('1,1,2,3,3,3,4,5'); }); + it.only('should return a linked list node array', () => { + const linkedList = new LinkedList(); + + expect(linkedList.head).toBeNull(); + expect(linkedList.tail).toBeNull(); + + linkedList.append(1); + linkedList.append(2); + + expect(linkedList.toArray().length).toBe(2); + + const linkedListNode2 = new LinkedListNode(2); + const linkedListNode1 = new LinkedListNode(1, linkedListNode2); + + expect(linkedList.toArray()).toEqual([linkedListNode1, linkedListNode2]); + }); + it('should find node by means of custom compare function', () => { const comparatorFunction = (a, b) => { if (a.customValue === b.customValue) { From e0de4bb37e807fcf424107e133ce791c3dc88843 Mon Sep 17 00:00:00 2001 From: JD Medina Date: Fri, 3 Jan 2020 07:08:50 -0500 Subject: [PATCH 2/2] Update LinkedList.test.js Remove only alias --- 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 d8f5e184..f2c9647d 100644 --- a/src/data-structures/linked-list/__test__/LinkedList.test.js +++ b/src/data-structures/linked-list/__test__/LinkedList.test.js @@ -193,7 +193,7 @@ describe('LinkedList', () => { expect(linkedList.toString()).toBe('1,1,2,3,3,3,4,5'); }); - it.only('should return a linked list node array', () => { + it('should return a linked list node array', () => { const linkedList = new LinkedList(); expect(linkedList.head).toBeNull();