Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 87c1dde

Browse files
committedApr 8, 2023
separate test for offset-based insert
1 parent a03f492 commit 87c1dde

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed
 

‎src/data-structures/linked-list/__test__/LinkedList.test.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,18 @@ describe('LinkedList', () => {
4545
linkedList.insert(10, 9);
4646

4747
expect(linkedList.toString()).toBe('1,4,2,3,10');
48+
});
4849

49-
linkedList.insert(7, 5);
50-
expect(linkedList.toString()).toBe('1,4,2,3,10,7');
51-
expect(linkedList.head.toString()).toBe('1');
52-
expect(linkedList.tail.toString()).toBe('7');
50+
it('should insert and maintain head and tail', () => {
51+
const linkedList = new LinkedList();
52+
53+
linkedList.insert(2, 0);
54+
linkedList.insert(3, 1);
55+
linkedList.insert(4, 2);
56+
57+
expect(linkedList.toString()).toBe('2,3,4');
58+
expect(linkedList.head.toString()).toBe('2');
59+
expect(linkedList.tail.toString()).toBe('4');
5360
});
5461

5562
it('should delete node by value from linked list', () => {

0 commit comments

Comments
 (0)
Please sign in to comment.