|
1 | 1 | const DLL = require('.');
|
2 | 2 |
|
3 | 3 | describe('Doubly Linked List', () => {
|
| 4 | + it('Should be class', () => { |
| 5 | + expect(typeof DLL.prototype.constructor).toEqual('function'); |
| 6 | + }); |
| 7 | + |
4 | 8 | const doublyLinkedList = new DLL();
|
5 | 9 |
|
6 |
| - it('create DLL', () => { |
| 10 | + it('It should create a DLL', () => { |
7 | 11 | expect(doublyLinkedList.head.next).toEqual(doublyLinkedList.tail);
|
8 | 12 | expect(doublyLinkedList.tail.previous).toEqual(doublyLinkedList.head);
|
9 | 13 | expect(doublyLinkedList.length()).toEqual(0);
|
10 | 14 | });
|
11 | 15 |
|
12 |
| - it('addAtBeginning', () => { |
| 16 | + it('It should add at beginning (addAtBeginning)', () => { |
13 | 17 | doublyLinkedList.addAtBeginning(1);
|
14 | 18 | doublyLinkedList.addAtBeginning(2);
|
15 | 19 | doublyLinkedList.addAtBeginning(3);
|
16 | 20 | expect(doublyLinkedList.traverse()).toEqual([3, 2, 1]);
|
17 | 21 | });
|
18 | 22 |
|
19 |
| - it('addAtEnd', () => { |
| 23 | + it('It should add at end (addAtEnd)', () => { |
20 | 24 | doublyLinkedList.addAtEnd(1);
|
21 | 25 | doublyLinkedList.addAtEnd(2);
|
22 | 26 | doublyLinkedList.addAtEnd(3);
|
23 | 27 | expect(doublyLinkedList.traverse()).toEqual([3, 2, 1, 1, 2, 3]);
|
24 | 28 | });
|
25 | 29 |
|
26 |
| - it('removeAtBeginning', () => { |
| 30 | + it('It should remove at beginning (removeAtBeginning)', () => { |
| 31 | + doublyLinkedList.removeAtBeginning(); |
27 | 32 | doublyLinkedList.removeAtBeginning();
|
28 | 33 | doublyLinkedList.removeAtBeginning();
|
29 |
| - doublyLinkedList.removeAtBeginning(); |
30 | 34 | expect(doublyLinkedList.traverse()).toEqual([1, 2, 3]);
|
31 | 35 | });
|
32 | 36 |
|
33 |
| - it('removeAtEnd', () => { |
| 37 | + it('It should remove at end (removeAtEnd)', () => { |
34 | 38 | doublyLinkedList.removeAtEnd();
|
35 | 39 | doublyLinkedList.removeAtEnd();
|
36 | 40 | doublyLinkedList.removeAtEnd();
|
|
0 commit comments