Files
Sebastian Poxhofer e9c9c92e10 test(oxlint): enable vitest/consistent-test-it (#44554)
refactor(oxlint): enable vitest/consistent-test-it

Enforce `it` over `test` in spec files via
vitest/consistent-test-it (fn: "it"), matching repo convention.
Renamed all 52 pre-existing `test(`/`test.each` usages across
13 spec files to `it(`/`it.each` using oxlint --fix.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 12:28:52 +00:00

57 lines
1.2 KiB
TypeScript

import { clone } from './clone.ts';
describe('util/clone', () => {
it.each`
input | expected
${undefined} | ${undefined}
${null} | ${null}
${true} | ${true}
${false} | ${false}
${0} | ${0}
${1} | ${1}
${NaN} | ${NaN}
${Infinity} | ${Infinity}
${-Infinity} | ${-Infinity}
${''} | ${''}
${'string'} | ${'string'}
${[]} | ${[]}
${[1, 2, 3]} | ${[1, 2, 3]}
${{}} | ${{}}
${{ a: 1 }} | ${{ a: 1 }}
`('returns $expected when input is $input', ({ input, expected }) => {
const res = clone(input);
expect(res).toStrictEqual(expected);
});
it('maintains same order', () => {
const obj: any = {
b: 'foo',
a: 'bar',
c: 'baz',
};
const res = clone(obj);
expect(Object.entries(res)).toMatchObject([
['b', 'foo'],
['a', 'bar'],
['c', 'baz'],
]);
});
it('assigns "[Circular]" to circular references', () => {
const obj: any = {
name: 'object',
type: 'object',
isObject: true,
};
obj.circular = obj;
expect(clone(obj)).toMatchObject({
circular: '[Circular]',
isObject: true,
name: 'object',
type: 'object',
});
});
});