Compare commits

...

3 Commits

Author SHA1 Message Date
David Medina
5a74d4a4c7
Merge e0de4bb37e into 2c67b48c21 2024-04-25 08:18:41 +08:00
JD Medina
e0de4bb37e Update LinkedList.test.js
Remove only alias
2020-01-03 07:08:50 -05:00
JD Medina
9caf9ebaaa Update LinkedList.test.js
Add a test to the LinkedList structure to test the toArray() method
2020-01-02 12:10:03 -05:00

View File

@ -1,4 +1,5 @@
import LinkedList from '../LinkedList';
import LinkedListNode from '../LinkedListNode';
describe('LinkedList', () => {
it('should create empty linked list', () => {
@ -207,6 +208,23 @@ describe('LinkedList', () => {
expect(linkedList.toString()).toBe('1,1,2,3,3,3,4,5');
});
it('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) {