import React from 'react'; import { isTruthyReactNode } from '../isTruthyNode'; describe('isTruthyReactNode', () => { it('should return false for null', () => { expect(isTruthyReactNode(null)).toBe(false); }); it('should return false for undefined', () => { expect(isTruthyReactNode(undefined)).toBe(false); }); it('should return false for false', () => { expect(isTruthyReactNode(false)).toBe(false); }); it('should return true for true', () => { expect(isTruthyReactNode(true)).toBe(true); }); it('should return true for string', () => { expect(isTruthyReactNode('hello')).toBe(true); }); it('should return true for empty string', () => { expect(isTruthyReactNode('')).toBe(true); }); it('should return true for number', () => { expect(isTruthyReactNode(42)).toBe(true); }); it('should return true for zero', () => { expect(isTruthyReactNode(0)).toBe(true); }); it('should return true for React element', () => { const element =
Test
; expect(isTruthyReactNode(element)).toBe(true); }); it('should return true for React fragment', () => { const fragment = ( <> Hello World ); expect(isTruthyReactNode(fragment)).toBe(true); }); it('should return true for array of React elements', () => { const array = [First, Second]; expect(isTruthyReactNode(array)).toBe(true); }); it('should return true for empty array', () => { expect(isTruthyReactNode([])).toBe(true); }); it('should return true for function component', () => { const Component = () =>
Component
; const element = ; expect(isTruthyReactNode(element)).toBe(true); }); });