mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-09-20 07:43:04 +08:00
tests linked list is iterable
This commit is contained in:
parent
218a9c3643
commit
c387aab2e7
@ -243,4 +243,17 @@ describe('LinkedList', () => {
|
|||||||
expect(linkedList.head.value).toBe(1);
|
expect(linkedList.head.value).toBe(1);
|
||||||
expect(linkedList.tail.value).toBe(3);
|
expect(linkedList.tail.value).toBe(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should be iterable', () => {
|
||||||
|
const linkedList = new LinkedList();
|
||||||
|
expect(typeof linkedList[Symbol.iterator]).toBe('function');
|
||||||
|
|
||||||
|
// Add test values to linked list.
|
||||||
|
linkedList
|
||||||
|
.append(1)
|
||||||
|
.append(2)
|
||||||
|
.append(3);
|
||||||
|
|
||||||
|
expect([...linkedList]).toEqual([1, 2, 3]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user