@public-ui/components
Version:
Contains all web components that belong to KoliBri - The accessible HTML-Standard.
62 lines (61 loc) • 3.26 kB
JavaScript
/*!
* KoliBri - The accessible HTML-Standard
*/
import { h } from "@stencil/core";
import { renderFunctionalComponentToSpecPage } from "../../../utils/testing";
import KolFormFieldLabelFc from "../FormFieldLabel";
describe('KolFormFieldLabelFc', () => {
it('should render with label', async () => {
const label = 'Test Label';
const id = 'test-id';
const page = await renderFunctionalComponentToSpecPage(() => h(KolFormFieldLabelFc, { label: label, id: id }));
expect(page.root).toMatchSnapshot();
});
it('should render with accessKey and shortKey', async () => {
const label = 'Test Label';
const accessKey = 'A';
const shortKey = 'S';
const id = 'test-id';
const page = await renderFunctionalComponentToSpecPage(() => h(KolFormFieldLabelFc, { label: label, accessKey: accessKey, shortKey: shortKey, id: id }));
expect(page.root).toMatchSnapshot();
});
it('should render with expert slot', async () => {
const id = 'test-id';
const page = await renderFunctionalComponentToSpecPage(() => (h(KolFormFieldLabelFc, { id: id, hasExpertSlot: true }, h("slot", { name: "expert" }, "Expert Content"))));
expect(page.root).toMatchSnapshot();
});
it('should set the correct id and class names', async () => {
var _a, _b, _c;
const label = 'Test Label';
const id = 'test-id';
const classNames = 'custom-class';
const page = await renderFunctionalComponentToSpecPage(() => h(KolFormFieldLabelFc, { label: label, id: id, class: classNames }));
expect((_a = page.root) === null || _a === void 0 ? void 0 : _a.id).toBe('test-id-label');
expect((_b = page.root) === null || _b === void 0 ? void 0 : _b.className).toContain('kol-form-field__label');
expect((_c = page.root) === null || _c === void 0 ? void 0 : _c.className).toContain(classNames);
});
it('should hide label when hideLabel is true', async () => {
var _a;
const label = 'Test Label';
const id = 'test-id';
const page = await renderFunctionalComponentToSpecPage(() => h(KolFormFieldLabelFc, { label: label, id: id, hideLabel: true }));
expect((_a = page.root) === null || _a === void 0 ? void 0 : _a.hidden).toBe(true);
});
it('should render the correct component tag "legend" ', async () => {
var _a;
const label = 'Test Label';
const id = 'test-id';
const page = await renderFunctionalComponentToSpecPage(() => h(KolFormFieldLabelFc, { label: label, id: id, component: "legend" }));
expect((_a = page.root) === null || _a === void 0 ? void 0 : _a.tagName).toBe('LEGEND');
expect(page.root).toMatchSnapshot();
});
it('should render the correct component tag "label" ', async () => {
var _a;
const label = 'Test Label';
const id = 'test-id';
const page = await renderFunctionalComponentToSpecPage(() => h(KolFormFieldLabelFc, { label: label, id: id, component: "label" }));
expect((_a = page.root) === null || _a === void 0 ? void 0 : _a.tagName).toBe('LABEL');
expect(page.root).toMatchSnapshot();
});
});
//# sourceMappingURL=snapshot.test.js.map