/*!
 * KoliBri - The accessible HTML-Standard
 */
import { h } from "@stencil/core";
import { renderFunctionalComponentToSpecPage } from "../../../utils/testing";
import KolFormFieldFc from "../FormField";
describe('KolFormFieldFc', () => {
    it('should render correctly', async () => {
        var _a;
        const page = await renderFunctionalComponentToSpecPage(() => h(KolFormFieldFc, { id: "test-id", label: "Test Label" }));
        expect(page.root).toMatchSnapshot();
        expect((_a = page.root) === null || _a === void 0 ? void 0 : _a.tagName).toBe('DIV');
    });
    it('should render correctly with fieldset tag', async () => {
        var _a;
        const page = await renderFunctionalComponentToSpecPage(() => h(KolFormFieldFc, { id: "test-id", label: "Test Label", component: "fieldset" }));
        expect(page.root).toMatchSnapshot();
        expect((_a = page.root) === null || _a === void 0 ? void 0 : _a.tagName).toBe('FIELDSET');
    });
    it('should render correctly with div tag', async () => {
        var _a;
        const page = await renderFunctionalComponentToSpecPage(() => h(KolFormFieldFc, { id: "test-id", label: "Test Label", component: "div" }));
        expect(page.root).toMatchSnapshot();
        expect((_a = page.root) === null || _a === void 0 ? void 0 : _a.tagName).toBe('DIV');
    });
    it('should render with required props', async () => {
        var _a;
        const page = await renderFunctionalComponentToSpecPage(() => h(KolFormFieldFc, { id: "test-id", label: "Test Label", required: true }));
        expect(page.root).toMatchSnapshot();
        expect((_a = page.root) === null || _a === void 0 ? void 0 : _a.className).toContain('required');
    });
    it('should render with error message', async () => {
        var _a;
        const msg = { _type: 'error', _description: 'Error message' };
        const page = await renderFunctionalComponentToSpecPage(() => h(KolFormFieldFc, { id: "test-id", label: "Test Label", msg: msg, touched: true }));
        expect(page.root).toMatchSnapshot();
        expect((_a = page.root) === null || _a === void 0 ? void 0 : _a.textContent).toContain('Error message');
    });
    it('should hide messages until touched', async () => {
        var _a;
        const msg = { _type: 'info', _description: 'Info message' };
        const page = await renderFunctionalComponentToSpecPage(() => h(KolFormFieldFc, { id: "test-id", label: "Test Label", msg: msg }));
        expect(page.root).toMatchSnapshot();
        expect((_a = page.root) === null || _a === void 0 ? void 0 : _a.textContent).not.toContain('Info message');
    });
    it('should render with hint', async () => {
        var _a;
        const hint = 'Hint message';
        const page = await renderFunctionalComponentToSpecPage(() => h(KolFormFieldFc, { id: "test-id", label: "Test Label", hint: hint }));
        expect(page.root).toMatchSnapshot();
        expect((_a = page.root) === null || _a === void 0 ? void 0 : _a.textContent).toContain(hint);
    });
    it('should render with tooltip', async () => {
        const page = await renderFunctionalComponentToSpecPage(() => h(KolFormFieldFc, { id: "test-id", label: "Test Label" }));
        expect(page.root).toMatchSnapshot();
    });
    it('should render with custom children', async () => {
        var _a;
        const page = await renderFunctionalComponentToSpecPage(() => (h(KolFormFieldFc, { id: "test-id", label: "Test Label" }, h("input", { type: "text" }))));
        expect(page.root).toMatchSnapshot();
        expect((_a = page.root) === null || _a === void 0 ? void 0 : _a.getElementsByTagName('input')).toHaveLength(1);
    });
});
//# sourceMappingURL=snapshot.test.js.map
