tests linked list is iterable

This commit is contained in:
Aonghus O Nia 2020-03-06 22:37:06 -05:00 committed by GitHub
parent 218a9c3643
commit c387aab2e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -243,4 +243,17 @@ describe('LinkedList', () => {
expect(linkedList.head.value).toBe(1);
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]);
});
});