@public-ui/components
Version:
Contains all web components that belong to KoliBri - The accessible HTML-Standard.
37 lines (36 loc) • 1.84 kB
JavaScript
/*!
* KoliBri - The accessible HTML-Standard
*/
import { h } from "@stencil/core";
import { renderFunctionalComponentToSpecPage } from "../../../utils/testing";
import FormFieldMsgFc from "../FormFieldMsg";
describe('FormFieldMsgFc', () => {
it('should render with all props', async () => {
const alert = true;
const msg = { _description: 'This is an error message', _type: 'error' };
const id = 'test-id';
const classNames = 'custom-class';
const page = await renderFunctionalComponentToSpecPage(() => h(FormFieldMsgFc, { alert: alert, msg: msg, id: id, class: classNames }));
expect(page.root).toMatchSnapshot();
});
it('should set the correct id', async () => {
var _a;
const id = 'test-id';
const page = await renderFunctionalComponentToSpecPage(() => h(FormFieldMsgFc, { id: id }));
expect((_a = page.root) === null || _a === void 0 ? void 0 : _a.id).toBe('test-id-msg');
});
it('should set the correct class names', async () => {
var _a;
const classNames = 'custom-class';
const page = await renderFunctionalComponentToSpecPage(() => h(FormFieldMsgFc, { id: "test-id", class: classNames }));
expect((_a = page.root) === null || _a === void 0 ? void 0 : _a.className).toContain(classNames);
});
it('should render the message correctly', async () => {
var _a;
const msg = { _description: 'This is an error message', _type: 'error' };
const page = await renderFunctionalComponentToSpecPage(() => h(FormFieldMsgFc, { id: "test-id", msg: msg }));
const ICON_LABEL = 'kol-error';
expect((_a = page.root) === null || _a === void 0 ? void 0 : _a.textContent).toBe(`${ICON_LABEL}${msg._description}`);
});
});
//# sourceMappingURL=snapshort.test.js.map