import { cleanup, render } from '@testing-library/react' import * as React from 'react' import { afterEach, describe, expect, it } from 'vitest' import ScriptBlock from './script-block' afterEach(() => { cleanup() }) type ScriptNode = { children: Array<{ value?: string }> } describe('ScriptBlock', () => { it('renders script tag string when child has value', () => { const node: ScriptNode = { children: [{ value: 'alert("hi")' }], } const { container } = render( , ) expect(container.textContent).toBe('') }) it('renders empty script tag when child value is undefined', () => { const node: ScriptNode = { children: [{}], } const { container } = render( , ) expect(container.textContent).toBe('') }) it('renders empty script tag when children array is empty', () => { const node: ScriptNode = { children: [], } const { container } = render( , ) expect(container.textContent).toBe('') }) it('preserves multiline script content', () => { const multi = `console.log("line1"); console.log("line2");` const node: ScriptNode = { children: [{ value: multi }], } const { container } = render( , ) expect(container.textContent).toBe(``) }) it('has displayName set correctly', () => { expect(ScriptBlock.displayName).toBe('ScriptBlock') }) })