Skip to main content
Glama
deleonio
by deleonio
snapshot.test.tsx2.28 kB
import { h } from '@stencil/core'; import { renderFunctionalComponentToSpecPage } from '../../../../utils/testing'; import NativeOptionFc from '../NativeOption'; describe('NativeOptionFc', () => { it('should render and match snapshot', async () => { const page = await renderFunctionalComponentToSpecPage(() => <NativeOptionFc value="testValue" label="testLabel" />); expect(page.root).toMatchSnapshot(); }); it('should render an option tag with the correct index and label', async () => { const page = await renderFunctionalComponentToSpecPage(() => <NativeOptionFc value="testValue" index={1} label="testLabel" />); expect(page.root).toMatchSnapshot(); const option = page.root; expect(option?.tagName).toBe('OPTION'); expect(option?.textContent).toBe('testLabel'); }); it('should set selected attribute correctly based on selectedValue', async () => { const page = await renderFunctionalComponentToSpecPage(() => <NativeOptionFc value="testValue" label="testLabel" selectedValue="testValue" />); expect(page.root).toMatchSnapshot(); const option = page.root; expect(option?.hasAttribute('selected')).toBe(true); }); it('should set selected attribute correctly based on selectedValue (with index as value)', async () => { const page = await renderFunctionalComponentToSpecPage(() => <NativeOptionFc index={-1} value="testValue" label="testLabel" selectedValue="testValue" />); expect(page.root).toMatchSnapshot(); const option = page.root; expect(option?.hasAttribute('selected')).toBe(true); }); it('should set selected attribute correctly based on selectedValue as number (with index as value)', async () => { const page = await renderFunctionalComponentToSpecPage(() => <NativeOptionFc index={-1} value={5} label="testLabel" selectedValue={5} />); expect(page.root).toMatchSnapshot(); const option = page.root; expect(option?.hasAttribute('selected')).toBe(true); }); it('should set selected attribute correctly based on selected prop', async () => { const page = await renderFunctionalComponentToSpecPage(() => <NativeOptionFc value="testValue" label="testLabel" selected />); expect(page.root).toMatchSnapshot(); const option = page.root; expect(option?.hasAttribute('selected')).toBe(true); }); });

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