2022-08-19 13:58:11 +00:00
|
|
|
import { clone } from './clone';
|
|
|
|
|
|
|
|
describe('util/clone', () => {
|
|
|
|
const obj: any = {
|
|
|
|
name: 'object',
|
|
|
|
type: 'object',
|
|
|
|
isObject: true,
|
|
|
|
};
|
|
|
|
|
2022-11-20 05:19:19 +00:00
|
|
|
it('returns null', () => {
|
|
|
|
const res = clone(null);
|
|
|
|
expect(res).toBeNull();
|
|
|
|
});
|
|
|
|
|
2022-08-19 13:58:11 +00:00
|
|
|
it('maintains same order', () => {
|
|
|
|
const res = clone(obj);
|
2022-11-20 05:19:19 +00:00
|
|
|
expect(res).toMatchSnapshot(`{
|
|
|
|
name: 'object',
|
|
|
|
type: 'object',
|
|
|
|
isObject: true,
|
|
|
|
}`);
|
2022-08-19 13:58:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('assigns "[Circular]" to circular references', () => {
|
|
|
|
obj.circular = obj;
|
|
|
|
const res = clone(obj);
|
|
|
|
expect(res.circular).toBe('[Circular]');
|
|
|
|
});
|
|
|
|
});
|