import React, { Fragment } from 'react'; import { isNativeHtmlStructure } from '../isNativeHtmlStructure'; describe('isNativeHtmlStructure', () => { it('returns true for primitive values', () => { expect(isNativeHtmlStructure(true)).toBe(true); expect(isNativeHtmlStructure(false)).toBe(true); expect(isNativeHtmlStructure(null)).toBe(true); expect(isNativeHtmlStructure(undefined)).toBe(true); expect(isNativeHtmlStructure('string')).toBe(true); expect(isNativeHtmlStructure(42)).toBe(true); expect(isNativeHtmlStructure(0)).toBe(true); expect(isNativeHtmlStructure('')).toBe(true); }); it('returns true for arrays of native HTML structures', () => { expect(isNativeHtmlStructure(['string', 42, null])).toBe(true); expect(isNativeHtmlStructure([
test
, 'text'])).toBe(true); expect(isNativeHtmlStructure([])).toBe(true); }); it('returns false for arrays containing non-native structures', () => { const CustomComponent = () =>
custom
; expect(isNativeHtmlStructure([])).toBe(false); expect(isNativeHtmlStructure(['text', ])).toBe(false); }); it('returns true for native HTML elements', () => { expect(isNativeHtmlStructure(
content
)).toBe(true); expect(isNativeHtmlStructure(text)).toBe(true); expect(isNativeHtmlStructure()).toBe(true); }); it('returns true for nested native HTML elements', () => { expect( isNativeHtmlStructure(
text
) ).toBe(true); }); it('returns true for native HTML elements with no children', () => { expect(isNativeHtmlStructure(
)).toBe(true); expect(isNativeHtmlStructure()).toBe(true); }); it('returns true for React fragments with native content', () => { expect( isNativeHtmlStructure(
test
text
) ).toBe(true); expect( isNativeHtmlStructure( <> content 42 ) ).toBe(true); }); it('returns true for empty React fragments', () => { expect(isNativeHtmlStructure()).toBe(true); expect(isNativeHtmlStructure(<>)).toBe(true); }); it('returns false for fragments containing custom components', () => { const CustomComponent = () =>
custom
; expect( isNativeHtmlStructure( ) ).toBe(false); }); it('returns false for custom function components', () => { const CustomComponent = () =>
custom
; expect(isNativeHtmlStructure()).toBe(false); }); it('returns false for custom class components', () => { class CustomComponent extends React.Component { render() { return
custom
; } } expect(isNativeHtmlStructure()).toBe(false); }); it('returns false for components with props', () => { const CustomComponent = ({ text, ...rest }: { text: string }) =>
{text}
; expect(isNativeHtmlStructure()).toBe(false); }); it('returns false for other symbol types', () => { const mockElement = { type: Symbol.for('react.provider'), props: { children: 'test' }, key: null, ref: null, }; expect(isNativeHtmlStructure(mockElement as unknown as React.ReactNode)).toBe(false); }); it('returns false for non-React element objects', () => { expect(isNativeHtmlStructure({ not: 'a react element' } as unknown as React.ReactNode)).toBe(false); expect(isNativeHtmlStructure({ type: 'div' } as unknown as React.ReactNode)).toBe(false); }); it('handles deeply nested native structures', () => { expect( isNativeHtmlStructure(

Title

Paragraph with bold text

  • Item 1
  • Item 2
) ).toBe(true); }); it('returns false for mixed native and custom components', () => { const CustomComponent = () =>
custom
; expect( isNativeHtmlStructure(
native
) ).toBe(false); }); it('handles nested arrays', () => { expect(isNativeHtmlStructure([
test
, ['nested', 'array', 42]])).toBe(true); const CustomComponent = () =>
custom
; expect(isNativeHtmlStructure([
test
, []])).toBe(false); }); it('returns false for unknown object types', () => { const unknownType = {}; expect(isNativeHtmlStructure(unknownType as unknown as React.ReactNode)).toBe(false); }); });