From b1e53b99d00aef58bfa3fd20a879725d6a8ea3b3 Mon Sep 17 00:00:00 2001 From: Adrian Mejia Date: Mon, 27 May 2019 10:04:36 -0400 Subject: [PATCH] test(linked-list): more coverage --- .../linked-lists/linked-list.spec.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/data-structures/linked-lists/linked-list.spec.js b/src/data-structures/linked-lists/linked-list.spec.js index 46a04075..288412c1 100644 --- a/src/data-structures/linked-lists/linked-list.spec.js +++ b/src/data-structures/linked-lists/linked-list.spec.js @@ -116,6 +116,12 @@ describe('LinkedList Test', () => { linkedList.addLast('found'); }); + describe('#length', () => { + it('should have length property', () => { + expect(linkedList.length).toBe(2); + }); + }); + describe('#indexOf', () => { it('should find element index', () => { expect(linkedList.indexOf(0)).toBe(0); @@ -203,6 +209,20 @@ describe('LinkedList Test', () => { expect(linkedList.size).toBe(2); }); }); + + describe('#removeByPosition', () => { + it('should remove last element', () => { + expect(linkedList.length).toBe(2); + expect(linkedList.removeByPosition(1)).toBe('found'); + expect(linkedList.length).toBe(1); + }); + + it('should remove last element', () => { + expect(linkedList.length).toBe(2); + expect(linkedList.removeByPosition(0)).toBe(0); + expect(linkedList.length).toBe(1); + }); + }); }); describe('Doubly Linked List and aliases', () => {