UNPKG

@public-ui/components

Version:

Contains all web components that belong to KoliBri - The accessible HTML-Standard.

50 lines (49 loc) 3.08 kB
/*! * KoliBri - The accessible HTML-Standard */ import { h } from "@stencil/core"; import { renderFunctionalComponentToSpecPage } from "../../../utils/testing"; import KolIconButtonFc from "../IconButton"; describe('KolIconButtonFc', () => { it('should render button component correctly', async () => { var _a, _b; const props = { componentName: 'button', label: 'Test Button', icon: 'test-icon' }; const page = await renderFunctionalComponentToSpecPage(() => h(KolIconButtonFc, Object.assign({}, props))); expect(page.root).toMatchSnapshot(); expect((_a = page.root) === null || _a === void 0 ? void 0 : _a.tagName).toBe('KOL-BUTTON-WC'); expect((_b = page.root) === null || _b === void 0 ? void 0 : _b.getAttribute('_label')).toContain('Test Button'); }); it('should render icon component correctly', async () => { var _a, _b; const props = { componentName: 'icon', icon: 'test-icon' }; const page = await renderFunctionalComponentToSpecPage(() => h(KolIconButtonFc, Object.assign({}, props))); expect(page.root).toMatchSnapshot(); expect((_a = page.root) === null || _a === void 0 ? void 0 : _a.tagName).toBe('I'); expect((_b = page.root) === null || _b === void 0 ? void 0 : _b.className).toContain('kol-icon'); }); it('should render icon with correct classes when componentName is icon', async () => { var _a, _b, _c, _d; const props = { componentName: 'icon', icon: 'fas fa-star', class: 'custom-icon-class' }; const page = await renderFunctionalComponentToSpecPage(() => h(KolIconButtonFc, Object.assign({}, props))); expect(page.root).toMatchSnapshot(); expect((_a = page.root) === null || _a === void 0 ? void 0 : _a.tagName).toBe('I'); expect((_b = page.root) === null || _b === void 0 ? void 0 : _b.className).toContain('kol-icon'); expect((_c = page.root) === null || _c === void 0 ? void 0 : _c.className).toContain('fas'); expect((_d = page.root) === null || _d === void 0 ? void 0 : _d.className).toContain('fa-star'); }); it('should handle onClick event', async () => { var _a; const onClick = jest.fn(); const props = { componentName: 'button', label: 'Test Button', icon: 'test-icon', onClick }; const page = await renderFunctionalComponentToSpecPage(() => h(KolIconButtonFc, Object.assign({}, props))); expect((_a = page.root) === null || _a === void 0 ? void 0 : _a.getAttribute('onClick')).toBeDefined(); }); it('should render with additional props', async () => { var _a; const props = { componentName: 'button', label: 'Test Button', icon: 'test-icon', class: 'custom-class' }; const page = await renderFunctionalComponentToSpecPage(() => h(KolIconButtonFc, Object.assign({}, props))); expect(page.root).toMatchSnapshot(); expect((_a = page.root) === null || _a === void 0 ? void 0 : _a.className).toContain('custom-class'); }); }); //# sourceMappingURL=snapshot.test.js.map