ant-design/components/_util/__tests__/reactNode.test.tsx

21 lines
607 B
TypeScript
Raw Normal View History

2022-10-14 12:05:58 +08:00
import React from 'react';
2024-02-24 14:50:03 +08:00
import { cloneElement, isFragment, replaceElement } from '../reactNode';
2022-10-14 12:05:58 +08:00
describe('reactNode test', () => {
it('isFragment', () => {
expect(isFragment(<p>test</p>)).toBe(false);
expect(isFragment(<>test</>)).toBe(true);
});
it('replaceElement', () => {
const node = <p>test</p>;
expect(replaceElement(null, node)).toBe(node);
expect(replaceElement(node, node)).toStrictEqual(node);
});
it('cloneElement', () => {
const node = <p>test</p>;
expect(cloneElement(null)).toBe(null);
expect(cloneElement(node)).toStrictEqual(node);
});
});