Skip to main content
Glama
deleonio
by deleonio
snapshot.test.tsx2.58 kB
import { h } from '@stencil/core'; import type { MsgPropType } from '../../../schema'; import { renderFunctionalComponentToSpecPage } from '../../../utils/testing'; import KolFormFieldFc from '../FormField'; describe('KolFormFieldFc', () => { it('should render correctly', async () => { const page = await renderFunctionalComponentToSpecPage(() => <KolFormFieldFc id="test-id" label="Test Label" />); expect(page.root).toMatchSnapshot(); expect(page.root?.tagName).toBe('DIV'); }); it('should render correctly with fieldset tag', async () => { const page = await renderFunctionalComponentToSpecPage(() => <KolFormFieldFc id="test-id" label="Test Label" component="fieldset" />); expect(page.root).toMatchSnapshot(); expect(page.root?.tagName).toBe('FIELDSET'); }); it('should render correctly with div tag', async () => { const page = await renderFunctionalComponentToSpecPage(() => <KolFormFieldFc id="test-id" label="Test Label" component="div" />); expect(page.root).toMatchSnapshot(); expect(page.root?.tagName).toBe('DIV'); }); it('should render with required props', async () => { const page = await renderFunctionalComponentToSpecPage(() => <KolFormFieldFc id="test-id" label="Test Label" required />); expect(page.root).toMatchSnapshot(); expect(page.root?.className).toContain('required'); }); it('should render with error message', async () => { const msg: MsgPropType = { _type: 'error', _description: 'Error message' }; const page = await renderFunctionalComponentToSpecPage(() => <KolFormFieldFc id="test-id" label="Test Label" msg={msg} touched />); expect(page.root).toMatchSnapshot(); expect(page.root?.textContent).toContain('Error message'); }); it('should render with hint', async () => { const hint = 'Hint message'; const page = await renderFunctionalComponentToSpecPage(() => <KolFormFieldFc id="test-id" label="Test Label" hint={hint} />); expect(page.root).toMatchSnapshot(); expect(page.root?.textContent).toContain(hint); }); it('should render with tooltip', async () => { const page = await renderFunctionalComponentToSpecPage(() => <KolFormFieldFc id="test-id" label="Test Label" tooltipAlign="right" />); expect(page.root).toMatchSnapshot(); }); it('should render with custom children', async () => { const page = await renderFunctionalComponentToSpecPage(() => ( <KolFormFieldFc id="test-id" label="Test Label"> <input type="text" /> </KolFormFieldFc> )); expect(page.root).toMatchSnapshot(); expect(page.root?.getElementsByTagName('input')).toHaveLength(1); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/deleonio/public-ui-kolibri'

If you have feedback or need assistance with the MCP directory API, please join our Discord server