Refactor: Implement SmartCube renderer, improve UI styling, and fix gaps
This commit is contained in:
33
node_modules/@gkucmierz/utils/spec/list-node.spec.mjs
generated
vendored
Normal file
33
node_modules/@gkucmierz/utils/spec/list-node.spec.mjs
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
import { ListNode } from '../src/list-node.mjs';
|
||||
|
||||
describe('ListNode', () => {
|
||||
it('constructor', () => {
|
||||
expect(new ListNode().val).toEqual(0);
|
||||
expect(new ListNode().next).toEqual(null);
|
||||
expect(new ListNode(123).val).toEqual(123);
|
||||
expect(new ListNode(123).next).toEqual(null);
|
||||
expect(new ListNode(123, 'next').next).toEqual('next');
|
||||
});
|
||||
|
||||
it('toArr', () => {
|
||||
expect(new ListNode().toArr()).toEqual([0]);
|
||||
expect(new ListNode(123).toArr()).toEqual([123]);
|
||||
expect(new ListNode(1, new ListNode(2)).toArr()).toEqual([1, 2]);
|
||||
});
|
||||
|
||||
it('fromArr', () => {
|
||||
expect(ListNode.fromArr([1, 2])).toEqual(new ListNode(1, new ListNode(2)));
|
||||
});
|
||||
|
||||
it('both', () => {
|
||||
const arr = [1, 2, 3, 4, 5];
|
||||
expect(ListNode.fromArr(arr).toArr()).toEqual(arr);
|
||||
});
|
||||
|
||||
it('cyclic reference', () => {
|
||||
const node = ListNode.fromArr([1, 2]);
|
||||
node.next.next = node;
|
||||
expect(() => node.toArr()).toThrow(new Error('Cyclic reference detected'));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user