diff --git a/packages/components/src/components/abbr/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/abbr/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..10bf1f49ff --- /dev/null +++ b/packages/components/src/components/abbr/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-abbr should render with _label="Text" _tooltipAlign="bottom" 1`] = ` + + + +`; + +exports[`kol-abbr should render with _label="Text" _tooltipAlign="left" 1`] = ` + + + +`; + +exports[`kol-abbr should render with _label="Text" _tooltipAlign="right" 1`] = ` + + + +`; + +exports[`kol-abbr should render with _label="Text" _tooltipAlign="top" 1`] = ` + + + +`; + +exports[`kol-abbr should render with _label="Text" 1`] = ` + + + +`; diff --git a/packages/components/src/components/abbr/test/html.mock.ts b/packages/components/src/components/abbr/test/html.mock.ts deleted file mode 100644 index bdc0e4f643..0000000000 --- a/packages/components/src/components/abbr/test/html.mock.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { mixMembers } from 'stencil-awesome-test'; - -import type { AbbrProps } from '../../../schema'; -import { KolTooltipWcTag } from '../../../core/component-names'; - -export const getAbbrHtml = (props: AbbrProps): string => { - props = mixMembers( - { - _label: '', // ⚠ required - _tooltipAlign: 'top', - }, - props, - ); - return ` - - - - - - - - <${KolTooltipWcTag} _align=${props._tooltipAlign} _id="nonce" _label=${props._label}> - -`; -}; diff --git a/packages/components/src/components/abbr/test/snapshot.spec.tsx b/packages/components/src/components/abbr/test/snapshot.spec.tsx index 640fa93331..462837030c 100644 --- a/packages/components/src/components/abbr/test/snapshot.spec.tsx +++ b/packages/components/src/components/abbr/test/snapshot.spec.tsx @@ -1,29 +1,17 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolAbbrTag } from '@component-names'; +import type { AbbrProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getAbbrHtml } from './html.mock'; - -import type { AbbrProps } from '../../../schema'; -import type { SpecPage } from '@stencil/core/testing'; import { KolAbbr } from '../shadow'; -executeTests( - 'Abbr', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolAbbr], - template: () => , - }); - return page; - }, - { - _label: ['Text'], - _tooltipAlign: ['left', 'bottom', 'right', 'top'], - }, - getAbbrHtml, - { - execMode: 'default', // ready - }, +executeSnapshotTests( + KolAbbrTag, + [KolAbbr], + [ + { _label: 'Text' }, + { _label: 'Text', _tooltipAlign: 'top' }, + { _label: 'Text', _tooltipAlign: 'left' }, + { _label: 'Text', _tooltipAlign: 'right' }, + { _label: 'Text', _tooltipAlign: 'bottom' }, + ], ); diff --git a/packages/components/src/components/accordion/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/accordion/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..11f80f1f90 --- /dev/null +++ b/packages/components/src/components/accordion/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,210 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-accordion should render with _label="Überschrift" _level=1 _open=false _disabled=false 1`] = ` + + + +`; + +exports[`kol-accordion should render with _label="Überschrift" _level=1 _open=false _disabled=true 1`] = ` + + + +`; + +exports[`kol-accordion should render with _label="Überschrift" _level=1 _open=true _disabled=false 1`] = ` + + + +`; + +exports[`kol-accordion should render with _label="Überschrift" _level=1 _open=true _disabled=true 1`] = ` + + + +`; + +exports[`kol-accordion should render with _label="Überschrift" _level=1 1`] = ` + + + +`; + +exports[`kol-accordion should render with _label="Überschrift" _level=2 1`] = ` + + + +`; + +exports[`kol-accordion should render with _label="Überschrift" _level=3 1`] = ` + + + +`; + +exports[`kol-accordion should render with _label="Überschrift" _level=4 1`] = ` + + + +`; + +exports[`kol-accordion should render with _label="Überschrift" _level=5 1`] = ` + + + +`; + +exports[`kol-accordion should render with _label="Überschrift" _level=6 1`] = ` + + + +`; + +exports[`kol-accordion should render with _label="Überschrift" 1`] = ` + + + +`; diff --git a/packages/components/src/components/accordion/test/html.mock.ts b/packages/components/src/components/accordion/test/html.mock.ts deleted file mode 100644 index cfe46aaeb1..0000000000 --- a/packages/components/src/components/accordion/test/html.mock.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { mixMembers } from 'stencil-awesome-test'; - -import type { AccordionProps } from '../../../schema'; -import { KolButtonWcTag, KolHeadingWcTag } from '../../../core/component-names'; - -export const getAccordionHtml = ( - props: AccordionProps, - slots: { - default?: string; - footer?: string; - } = {}, -): string => { - props = mixMembers( - { - _label: '', // ⚠ required - _level: 1, - }, - props, - ); - return ` - -
- <${KolHeadingWcTag} _label="" _level="${props._level}" class="accordion__heading collapsible__heading"> - <${KolButtonWcTag} - class="accordion__heading-button collapsible__heading-button" - slot="expert" - _ariaControls="nonce-control" - ${props._open ? '_ariaExpanded=""' : ''} - ${props._disabled ? '_disabled=""' : ''} - _icons="codicon codicon-${props._open ? 'remove' : 'add'}" - _label="${props._label}" - > - - -
-
-
- -
-
- -
- - ${slots.default !== undefined ? slots.default : ''} - ${slots.footer !== undefined ? slots.footer : ''} -`; -}; diff --git a/packages/components/src/components/accordion/test/snapshot.spec.tsx b/packages/components/src/components/accordion/test/snapshot.spec.tsx index cd39d91a1e..fe85a0b78f 100644 --- a/packages/components/src/components/accordion/test/snapshot.spec.tsx +++ b/packages/components/src/components/accordion/test/snapshot.spec.tsx @@ -1,31 +1,25 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolAccordionTag } from '@component-names'; +import type { AccordionProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; +import { KolAccordion } from '../shadow'; -import { getAccordionHtml } from './html.mock'; +// _disabled: [true, false], +// _label: ['Überschrift'], +// _level: [1, 2, 3, 4, 5, 6], +// _open: [true, false], -import type { AccordionProps } from '../../../schema'; -import type { SpecPage } from '@stencil/core/testing'; -import { KolAccordion } from '../shadow'; +const baseObject = { _label: 'Überschrift' }; -executeTests( - 'Accordion', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolAccordion], - template: () => , - }); - return page; - }, - { - _disabled: [true, false], - _label: ['Überschrift'], - _level: [1, 2, 3, 4, 5, 6], - _open: [true, false], - }, - getAccordionHtml, - { - execMode: 'default', // ready - }, +executeSnapshotTests( + KolAccordionTag, + [KolAccordion], + [ + { ...baseObject }, + ...([1, 2, 3, 4, 5, 6].map((_level) => ({ ...baseObject, _level })) as AccordionProps[]), + { ...baseObject, _level: 1, _open: false, _disabled: false }, + { ...baseObject, _level: 1, _open: false, _disabled: true }, + { ...baseObject, _level: 1, _open: true, _disabled: true }, + { ...baseObject, _level: 1, _open: true, _disabled: false }, + ], ); diff --git a/packages/components/src/components/alert/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/alert/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..08378d3abf --- /dev/null +++ b/packages/components/src/components/alert/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,1261 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=1 _type="default" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=1 _type="error" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=1 _type="info" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=1 _type="success" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=1 _type="warning" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=2 _type="default" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=2 _type="error" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=2 _type="info" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=2 _type="success" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=2 _type="warning" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=3 _type="default" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=3 _type="error" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=3 _type="info" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=3 _type="success" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=3 _type="warning" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=4 _type="default" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=4 _type="error" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=4 _type="info" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=4 _type="success" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=4 _type="warning" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=5 _type="default" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=5 _type="error" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=5 _type="info" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=5 _type="success" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=5 _type="warning" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=6 _type="default" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=6 _type="error" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=6 _type="info" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=6 _type="success" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=false _level=6 _type="warning" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=1 _type="default" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=1 _type="error" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=1 _type="info" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=1 _type="success" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=1 _type="warning" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=2 _type="default" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=2 _type="error" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=2 _type="info" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=2 _type="success" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=2 _type="warning" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=3 _type="default" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=3 _type="error" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=3 _type="info" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=3 _type="success" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=3 _type="warning" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=4 _type="default" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=4 _type="error" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=4 _type="info" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=4 _type="success" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=4 _type="warning" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=5 _type="default" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=5 _type="error" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=5 _type="info" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=5 _type="success" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=5 _type="warning" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=6 _type="default" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=6 _type="error" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=6 _type="info" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=6 _type="success" 1`] = ` + + + +`; + +exports[`kol-alert should render with _label="Überschrift" _alert=true _level=6 _type="warning" 1`] = ` + + + +`; diff --git a/packages/components/src/components/alert/test/html.mock.ts b/packages/components/src/components/alert/test/html.mock.ts deleted file mode 100644 index 9e33bf6697..0000000000 --- a/packages/components/src/components/alert/test/html.mock.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { mixMembers } from 'stencil-awesome-test'; - -import { translate } from '../../../i18n'; - -import type { AlertProps } from '../../../schema'; -import { KolIconTag, KolHeadingWcTag, KolButtonWcTag } from '../../../core/component-names'; -export const getAlertHtml = (props: AlertProps, innerHTML = '', additionalHTML = ''): string => { - props = mixMembers( - { - _level: 1, - }, - props, - ); - const type: string = props._type !== undefined ? props._type : 'default'; - props._type = props._type || 'default'; - props._variant = props._variant || 'msg'; - - return ` - - - - - - ${innerHTML} -`; -}; diff --git a/packages/components/src/components/alert/test/snapshot.spec.tsx b/packages/components/src/components/alert/test/snapshot.spec.tsx index d9fb651985..f64f00e647 100644 --- a/packages/components/src/components/alert/test/snapshot.spec.tsx +++ b/packages/components/src/components/alert/test/snapshot.spec.tsx @@ -1,32 +1,29 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolAlertTag } from '@component-names'; +import type { AlertProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getAlertHtml } from './html.mock'; - -import type { AlertProps } from '../../../schema'; -import type { SpecPage } from '@stencil/core/testing'; import { KolAlert } from '../shadow'; import { KolAlertWc } from '../component'; -executeTests( - 'Alert', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolAlert, KolAlertWc], - template: () => , - }); - return page; - }, - { - _alert: [false, true], - _label: ['Überschrift'], - _level: [1, 2, 3, 4, 5, 6], - _type: ['default', 'error', 'info', 'success', 'warning'], - }, - getAlertHtml, - { - needTimers: true, - }, +// _alert: [false, true], +// _label: ['Überschrift'], +// _level: [1, 2, 3, 4, 5, 6], +// _type: ['default', 'error', 'info', 'success', 'warning'], + +const baseObject = { _label: 'Überschrift' }; +const baseArray = [true, false].map((_alert) => ({ ...baseObject, _alert })); + +function buildByType(_type: 'default' | 'error' | 'info' | 'success' | 'warning') { + const nextArray: AlertProps[] = []; + [1, 2, 3, 4, 5, 6].forEach((_level) => { + nextArray.push(...baseArray.map((o) => ({ ...o, _level, _type }) as AlertProps)); + }); + + return nextArray; +} + +executeSnapshotTests( + KolAlertTag, + [KolAlert, KolAlertWc], + [...buildByType('default'), ...buildByType('error'), ...buildByType('info'), ...buildByType('success'), ...buildByType('warning')], ); diff --git a/packages/components/src/components/badge/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/badge/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..201867ed90 --- /dev/null +++ b/packages/components/src/components/badge/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,51 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-badge should render with _label="**Te**xt" 1`] = ` + + + +`; + +exports[`kol-badge should render with _label="Text" _color="#000000" 1`] = ` + + + +`; + +exports[`kol-badge should render with _label="Text" _icons="codicon codicon-home" _color="#000000" 1`] = ` + + + +`; + +exports[`kol-badge should render with _label="Text" _icons="codicon codicon-home" 1`] = ` + + + +`; + +exports[`kol-badge should render with _label="Text" 1`] = ` + + + +`; diff --git a/packages/components/src/components/badge/test/html.mock.ts b/packages/components/src/components/badge/test/html.mock.ts deleted file mode 100644 index 7e255cd40f..0000000000 --- a/packages/components/src/components/badge/test/html.mock.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { mixMembers } from 'stencil-awesome-test'; - -import { handleColorChange } from '../../../schema'; - -import type { BadgeProps, BadgeStates } from '../../../schema'; -import type { SpanOptions } from '../../span/test/html.mock'; -import { KolSpanWcTag } from '../../../core/component-names'; - -export const getBadgeHtml = (props: BadgeProps, options?: SpanOptions): string => { - const state = mixMembers( - { - _color: { - backgroundColor: '#000', - foregroundColor: '#fff', - }, - }, - props, - ); - - state._color = handleColorChange(props._color || '#000'); - - return ` - - - <${KolSpanWcTag} _allowMarkdown ${props._icons ? `_icons="${props._icons as string}"` : ''} ${props._label ? `_label="${props._label}"` : ''}> - - -`; -}; diff --git a/packages/components/src/components/badge/test/snapshot.spec.tsx b/packages/components/src/components/badge/test/snapshot.spec.tsx index 9e6ba4de14..150ba59a7f 100644 --- a/packages/components/src/components/badge/test/snapshot.spec.tsx +++ b/packages/components/src/components/badge/test/snapshot.spec.tsx @@ -1,30 +1,17 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolBadgeTag } from '@component-names'; +import type { BadgeProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getBadgeHtml } from './html.mock'; - -import type { BadgeProps } from '../../../schema'; -import type { SpecPage } from '@stencil/core/testing'; import { KolBadge } from '../shadow'; -executeTests( - 'Badge', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolBadge], - template: () => , - }); - return page; - }, - { - _color: ['#000000'], - _icons: ['codicon codicon-home'], - _label: ['Text', '**Te**xt'], - }, - (props) => getBadgeHtml(props), - { - execMode: 'default', // ready - }, +executeSnapshotTests( + KolBadgeTag, + [KolBadge], + [ + { _label: 'Text' }, + { _label: '**Te**xt' }, + { _label: 'Text', _color: '#000000' }, + { _label: 'Text', _icons: 'codicon codicon-home' }, + { _label: 'Text', _icons: 'codicon codicon-home', _color: '#000000' }, + ], ); diff --git a/packages/components/src/components/breadcrumb/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/breadcrumb/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..766eb4788c --- /dev/null +++ b/packages/components/src/components/breadcrumb/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,17 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-breadcrumb should render with _label="Aria-Label" _links=[{"_href":"www.google.de","_label":"Label"}] 1`] = ` + + + +`; diff --git a/packages/components/src/components/breadcrumb/test/html.mock.ts b/packages/components/src/components/breadcrumb/test/html.mock.ts deleted file mode 100644 index bb9407d53d..0000000000 --- a/packages/components/src/components/breadcrumb/test/html.mock.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { mixMembers } from 'stencil-awesome-test'; - -import { KolIconTag, KolLinkTag } from '../../../core/component-names'; - -import type { AnyIconFontClass, BreadcrumbLinkProps, BreadcrumbProps, LabelPropType } from '../../../schema'; - -export const getBreadcrumbHtml = (props: BreadcrumbProps): string => { - const state = mixMembers( - { - _label: '', // ⚠ required - _links: [], - }, - props, - ); - - const lastIndex = state._links.length - 1; - let list = ''; - (state._links as BreadcrumbLinkProps[]).forEach((link, index) => { - list += ` -
  • - ${index !== 0 ? `<${KolIconTag} _label="" _icons="codicon codicon-chevron-right" /> ` : ''} - ${ - lastIndex === index - ? `${link._hideLabel ? `<${KolIconTag} _label="${link._label}" _icons="${link._icons as AnyIconFontClass}" />` : link._label}` - : `<${KolLinkTag} {...link}>` - } -
  • - `; - }); - - return ` - - - - -`; -}; diff --git a/packages/components/src/components/breadcrumb/test/snapshot.spec.tsx b/packages/components/src/components/breadcrumb/test/snapshot.spec.tsx index 65ab62ed7d..211ac4c708 100644 --- a/packages/components/src/components/breadcrumb/test/snapshot.spec.tsx +++ b/packages/components/src/components/breadcrumb/test/snapshot.spec.tsx @@ -1,29 +1,7 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolBreadcrumbTag } from '@component-names'; +import type { BreadcrumbProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getBreadcrumbHtml } from './html.mock'; - -import type { SpecPage } from '@stencil/core/testing'; -import type { BreadcrumbProps } from '../../../schema'; import { KolBreadcrumb } from '../shadow'; -executeTests( - 'Breadcrumb', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolBreadcrumb], - template: () => , - }); - return page; - }, - { - _label: ['Aria-Label'], - _links: [[], [{ _label: 'Label' }]], - }, - getBreadcrumbHtml, - { - execMode: 'default', // ready - }, -); +executeSnapshotTests(KolBreadcrumbTag, [KolBreadcrumb], [{ _label: 'Aria-Label', _links: [{ _href: 'www.google.de', _label: 'Label' }] }]); diff --git a/packages/components/src/components/button-group/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/button-group/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..5cf217f009 --- /dev/null +++ b/packages/components/src/components/button-group/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,12 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-button-group should render with 1`] = ` + + + +`; diff --git a/packages/components/src/components/button-group/test/html.mock.ts b/packages/components/src/components/button-group/test/html.mock.ts deleted file mode 100644 index 40e0671f5c..0000000000 --- a/packages/components/src/components/button-group/test/html.mock.ts +++ /dev/null @@ -1,9 +0,0 @@ -export const getButtonGroupHtml = (): string => { - return ` - - - - - -`; -}; diff --git a/packages/components/src/components/button-group/test/snapshot.spec.tsx b/packages/components/src/components/button-group/test/snapshot.spec.tsx index fbca294779..944c7d0690 100644 --- a/packages/components/src/components/button-group/test/snapshot.spec.tsx +++ b/packages/components/src/components/button-group/test/snapshot.spec.tsx @@ -1,26 +1,8 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolButtonGroupTag } from '@component-names'; +// import type { ButtonGroupAPI } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getButtonGroupHtml } from './html.mock'; - -import type { SpecPage } from '@stencil/core/testing'; -import type { ButtonGroupProps } from '../../../schema'; import { KolButtonGroup } from '../shadow'; import { KolButtonGroupWc } from '../component'; -executeTests( - 'ButtonGroup', - async (props): Promise => { - return await newSpecPage({ - components: [KolButtonGroup, KolButtonGroupWc], - template: () => , - }); - }, - {}, - getButtonGroupHtml, - { - execMode: 'default', - }, -); +executeSnapshotTests(KolButtonGroupTag, [KolButtonGroup, KolButtonGroupWc], [{}]); diff --git a/packages/components/src/components/button-link/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/button-link/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..fb439cf493 --- /dev/null +++ b/packages/components/src/components/button-link/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-button-link should render with _label="Beschreibung" 1`] = ` + + + +`; diff --git a/packages/components/src/components/button-link/test/html.mock.ts b/packages/components/src/components/button-link/test/html.mock.ts deleted file mode 100644 index a432c2c28e..0000000000 --- a/packages/components/src/components/button-link/test/html.mock.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { mixMembers } from 'stencil-awesome-test'; -import type { ButtonLinkProps, ButtonLinkStates } from '../../../schema'; -import { KolButtonWcTag } from '../../../core/component-names'; - -export const getButtonLinkHtml = (props: ButtonLinkProps): string => { - const state = mixMembers( - { - _icons: {}, - _label: '', // ⚠ required - _on: {}, - _type: 'button', - _variant: 'normal', - }, - props, - ); - - return ` - - <${KolButtonWcTag} - _role="link" - _type="button" - ${state._label ? `_label="${state._label}"` : ''} - _tooltipalign="top" - > - - - - `; -}; diff --git a/packages/components/src/components/button-link/test/snapshot.spec.tsx b/packages/components/src/components/button-link/test/snapshot.spec.tsx index 814a85ed1e..dded60070f 100644 --- a/packages/components/src/components/button-link/test/snapshot.spec.tsx +++ b/packages/components/src/components/button-link/test/snapshot.spec.tsx @@ -1,24 +1,7 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolButtonLinkTag } from '@component-names'; +import type { ButtonLinkProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getButtonLinkHtml } from './html.mock'; - -import type { ButtonLinkProps } from '../../../schema'; -import type { SpecPage } from '@stencil/core/testing'; import { KolButtonLink } from '../shadow'; -executeTests( - 'ButtonLink', - async (props): Promise => { - return await newSpecPage({ - components: [KolButtonLink], - template: () => , - }); - }, - { - _label: [`Beschreibung`], - }, - getButtonLinkHtml, -); +executeSnapshotTests(KolButtonLinkTag, [KolButtonLink], [{ _label: 'Beschreibung' }]); diff --git a/packages/components/src/components/button/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/button/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..598e2bf0af --- /dev/null +++ b/packages/components/src/components/button/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,164 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-button should render with _label="Label" _ariaDescription="Aria Description" 1`] = ` + + + +`; + +exports[`kol-button should render with _label="Label" _disabled=false 1`] = ` + + + +`; + +exports[`kol-button should render with _label="Label" _disabled=true 1`] = ` + + + +`; + +exports[`kol-button should render with _label="Label" _value="Hello" 1`] = ` + + + +`; + +exports[`kol-button should render with _label="Label" _variant="danger" 1`] = ` + + + +`; + +exports[`kol-button should render with _label="Label" _variant="ghost" 1`] = ` + + + +`; + +exports[`kol-button should render with _label="Label" _variant="normal" 1`] = ` + + + +`; + +exports[`kol-button should render with _label="Label" _variant="primary" 1`] = ` + + + +`; + +exports[`kol-button should render with _label="Label" _variant="secondary" 1`] = ` + + + +`; + +exports[`kol-button should render with _label="Label" 1`] = ` + + + +`; diff --git a/packages/components/src/components/button/test/html.mock.ts b/packages/components/src/components/button/test/html.mock.ts deleted file mode 100644 index 4ca2c287b1..0000000000 --- a/packages/components/src/components/button/test/html.mock.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { mixMembers } from 'stencil-awesome-test'; - -import { showExpertSlot } from '../../../schema'; - -import clsx from 'clsx'; - -import type { ButtonProps, ButtonStates } from '../../../schema'; -import { KolSpanWcTag, KolTooltipWcTag } from '../../../core/component-names'; - -export const getButtonWcHtml = (props: ButtonProps, additionalAttrs = ''): string => { - const state = mixMembers( - { - _icons: {}, - _label: '', // ⚠ required - _on: {}, - _type: 'button', - _variant: 'normal', - }, - props, - ); - const ariaControls = typeof state._ariaControls === 'string' ? state._ariaControls : undefined; - const ariaExpanded = typeof state._ariaExpanded === 'boolean' ? state._ariaExpanded : undefined; - const hasExpertSlot = showExpertSlot(state._label); - const type = typeof state._type === 'string' ? state._type : 'button'; - const variant = typeof state._variant === 'string' ? state._variant : 'normal'; - - const classNames = clsx({ - button: true, - disabled: state._disabled, - 'hide-label': state._hideLabel, - [variant]: true, - }); - - return ` - - - <${KolSpanWcTag} - class="button-inner" - _label="${hasExpertSlot ? '' : state._label}" - > - - - - - <${KolTooltipWcTag} - aria-hidden="true" - hidden="" - ${state._tooltipAlign ? `_align=${state._tooltipAlign}` : "_align='top'"} - _label="${typeof state._label === 'string' ? state._label : ''}" - > -`; -}; - -export const getButtonHtml = (props: ButtonProps): string => { - const state = mixMembers( - { - _icons: {}, - _label: '', // ⚠ required - _type: 'button', - _variant: 'normal', - }, - props, - ); - return ` - - ${getButtonWcHtml(props, ` class="kol-button-wc button ${state._variant}"`)} - -`; -}; diff --git a/packages/components/src/components/button/test/snapshot.spec.tsx b/packages/components/src/components/button/test/snapshot.spec.tsx index 54ce9c91ad..2eb9781743 100644 --- a/packages/components/src/components/button/test/snapshot.spec.tsx +++ b/packages/components/src/components/button/test/snapshot.spec.tsx @@ -1,28 +1,29 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolButtonTag } from '@component-names'; +import type { ButtonProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getButtonHtml } from './html.mock'; - -import type { SpecPage } from '@stencil/core/testing'; -import type { ButtonProps } from '../../../schema'; import { KolButton } from '../shadow'; import { KolButtonWc } from '../component'; -executeTests( - 'Button', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolButton, KolButtonWc], - template: () => , - }); - return page; - }, - { - _disabled: [true, false], - _label: ['Label'], - _variant: ['primary', 'secondary', 'normal', 'danger', 'ghost'], - }, - getButtonHtml, +executeSnapshotTests( + KolButtonTag, + [KolButton, KolButtonWc], + [ + { _label: 'Label' }, + + { _label: 'Label', _disabled: false }, + { _label: 'Label', _disabled: true }, + + ...['primary', 'secondary', 'normal', 'danger', 'ghost'].map( + (_variant) => + ({ + _label: 'Label', + _variant, + }) as ButtonProps, + ), + + { _label: 'Label', _value: 'Hello' }, + + { _label: 'Label', _ariaDescription: 'Aria Description' }, + ], ); diff --git a/packages/components/src/components/card/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/card/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..e5d971dc1e --- /dev/null +++ b/packages/components/src/components/card/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,338 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-card should render with _label="Überschrift" _level=0 _hasCloser=false 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" _level=0 _hasCloser=true 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" _level=0 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" _level=1 _hasCloser=false 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" _level=1 _hasCloser=true 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" _level=1 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" _level=2 _hasCloser=false 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" _level=2 _hasCloser=true 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" _level=2 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" _level=3 _hasCloser=false 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" _level=3 _hasCloser=true 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" _level=3 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" _level=4 _hasCloser=false 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" _level=4 _hasCloser=true 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" _level=4 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" _level=5 _hasCloser=false 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" _level=5 _hasCloser=true 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" _level=5 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" _level=6 _hasCloser=false 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" _level=6 _hasCloser=true 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" _level=6 1`] = ` + + + +`; + +exports[`kol-card should render with _label="Überschrift" 1`] = ` + + + +`; diff --git a/packages/components/src/components/card/test/html.mock.ts b/packages/components/src/components/card/test/html.mock.ts deleted file mode 100644 index cd95fa5f27..0000000000 --- a/packages/components/src/components/card/test/html.mock.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { mixMembers } from 'stencil-awesome-test'; - -import type { CardProps } from '../../../schema'; -import { KolHeadingWcTag, KolButtonWcTag } from '../../../core/component-names'; - -export const getCardHtml = (props: CardProps): string => { - props = mixMembers( - { - _label: '', // ⚠ required - }, - props, - ); - return ` - -
    -
    - <${KolHeadingWcTag} _label="${props._label}" _level="${props._level ? props._level : '1'}"> -
    -
    - -
    - ${ - props._hasCloser - ? `<${KolButtonWcTag} - class="close" - _hideLabel="" - _label='kol-close' - _tooltipAlign="left" - >` - : `` - } -
    -
    -
    `; -}; diff --git a/packages/components/src/components/card/test/snapshot.spec.tsx b/packages/components/src/components/card/test/snapshot.spec.tsx index b0194ea281..4fde5b1e85 100644 --- a/packages/components/src/components/card/test/snapshot.spec.tsx +++ b/packages/components/src/components/card/test/snapshot.spec.tsx @@ -1,30 +1,37 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolCardTag } from '@component-names'; +import type { CardProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; +import { KolCard } from '../shadow'; -import { getCardHtml } from './html.mock'; +executeSnapshotTests( + KolCardTag, + [KolCard], + [ + { _label: 'Überschrift' }, -import type { SpecPage } from '@stencil/core/testing'; -import type { CardProps } from '../../../schema'; -import { KolCard } from '../shadow'; + { _label: 'Überschrift', _level: 0 }, + { _label: 'Überschrift', _level: 1 }, + { _label: 'Überschrift', _level: 2 }, + { _label: 'Überschrift', _level: 3 }, + { _label: 'Überschrift', _level: 4 }, + { _label: 'Überschrift', _level: 5 }, + { _label: 'Überschrift', _level: 6 }, + + { _label: 'Überschrift', _level: 0, _hasCloser: false }, + { _label: 'Überschrift', _level: 1, _hasCloser: false }, + { _label: 'Überschrift', _level: 2, _hasCloser: false }, + { _label: 'Überschrift', _level: 3, _hasCloser: false }, + { _label: 'Überschrift', _level: 4, _hasCloser: false }, + { _label: 'Überschrift', _level: 5, _hasCloser: false }, + { _label: 'Überschrift', _level: 6, _hasCloser: false }, -executeTests( - 'Card', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolCard], - template: () => , - }); - return page; - }, - { - _hasCloser: [false, true], - _label: ['Überschrift'], - _level: [1, 2, 3, 4, 5, 6], - }, - getCardHtml, - { - execMode: 'default', // ready - }, + { _label: 'Überschrift', _level: 0, _hasCloser: true }, + { _label: 'Überschrift', _level: 1, _hasCloser: true }, + { _label: 'Überschrift', _level: 2, _hasCloser: true }, + { _label: 'Überschrift', _level: 3, _hasCloser: true }, + { _label: 'Überschrift', _level: 4, _hasCloser: true }, + { _label: 'Überschrift', _level: 5, _hasCloser: true }, + { _label: 'Überschrift', _level: 6, _hasCloser: true }, + ], ); diff --git a/packages/components/src/components/combobox/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/combobox/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..da468672a3 --- /dev/null +++ b/packages/components/src/components/combobox/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,217 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-combobox should render with _label="Label" _suggestions=["Frau","Herr","Divers"] _disabled=true 1`] = ` + + + +`; + +exports[`kol-combobox should render with _label="Label" _suggestions=["Frau","Herr","Divers"] _hideError=false 1`] = ` + + + +`; + +exports[`kol-combobox should render with _label="Label" _suggestions=["Frau","Herr","Divers"] _hideError=true 1`] = ` + + + +`; + +exports[`kol-combobox should render with _label="Label" _suggestions=["Frau","Herr","Divers"] _icons={"left":{"icon":"codicon codicon-arrow-left"},"right":{"icon":"codicon codicon-arrow-right"}} 1`] = ` + + + +`; + +exports[`kol-combobox should render with _label="Label" _suggestions=["Frau","Herr","Divers"] _required=false 1`] = ` + + + +`; + +exports[`kol-combobox should render with _label="Label" _suggestions=["Frau","Herr","Divers"] _required=true 1`] = ` + + + +`; + +exports[`kol-combobox should render with _label="Label" _suggestions=["Frau","Herr","Divers"] _touched=false 1`] = ` + + + +`; + +exports[`kol-combobox should render with _label="Label" _suggestions=["Frau","Herr","Divers"] _touched=true 1`] = ` + + + +`; + +exports[`kol-combobox should render with _label="Label" _suggestions=["Frau","Herr","Divers"] 1`] = ` + + + +`; diff --git a/packages/components/src/components/combobox/test/html.mock.ts b/packages/components/src/components/combobox/test/html.mock.ts deleted file mode 100644 index 6116b01c96..0000000000 --- a/packages/components/src/components/combobox/test/html.mock.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { mixMembers } from 'stencil-awesome-test'; -import { nonce } from '../../../utils/dev.utils'; - -import { showExpertSlot, type ComboboxProps, type ComboboxStates } from '../../../schema'; -import { KolInputTag } from '../../../core/component-names'; -import clsx from 'clsx'; - -interface ExtendedComboboxStates extends ComboboxStates { - _isOpen?: boolean; - blockSuggestionMouseOver?: boolean; -} - -export const getComboboxHtml = (props: ComboboxProps): string => { - const state = mixMembers( - { - _hasValue: true, - _hideError: false, - _id: `id-${nonce()}`, - _label: '', // ⚠ required - _suggestions: [], - _value: '', - _isOpen: false, - blockSuggestionMouseOver: false, - }, - props, - ); - const hasExpertSlot = showExpertSlot(state._label); - - return ` - - -
    - <${KolInputTag} - ${state._hideError ? '_hideerror=""' : ''} - _hint="" - _id="id-nonce" - _label="${typeof state._label === 'string' ? state._label : ''}" - _tooltipalign="top" - role="presentation" - ${state._required ? ' _required=""' : ''} - ${state._touched ? ' _touched=""' : ''} - ${(state._alert === undefined && state._touched) || state._alert ? `_alert=""` : ''} - > - - ${ - hasExpertSlot - ? `` - : typeof state._accessKey === 'string' - ? `<> - {' '} - - ` - : `${state._label}` - } - -
    -
    - - - -
    - ${ - state._isOpen && !(state._disabled === true) - ? `
      ${ - Array.isArray(state._suggestions) && - state._suggestions.length > 0 && - state._suggestions - .map((option, index) => { - return `
    • ${option}
    • `; - }) - .join('') - }
    ` - : '' - } -
    - -
    -
    -
    `; -}; diff --git a/packages/components/src/components/combobox/test/snapshot.spec.tsx b/packages/components/src/components/combobox/test/snapshot.spec.tsx index 87d46225b9..f317c11078 100644 --- a/packages/components/src/components/combobox/test/snapshot.spec.tsx +++ b/packages/components/src/components/combobox/test/snapshot.spec.tsx @@ -1,28 +1,21 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolComboboxTag } from '@component-names'; +import type { ComboboxProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getComboboxHtml } from './html.mock'; - -import type { ComboboxProps } from '../../../schema'; -import type { SpecPage } from '@stencil/core/testing'; import { KolCombobox } from '../shadow'; -executeTests( - 'Combobox', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolCombobox], - template: () => , - }); - return page; - }, - { - _hideError: [false, true], - _suggestions: ['Frau', 'Herr', 'Divers'], - _icons: [ - { +const baseObj: ComboboxProps = { _label: 'Label', _suggestions: ['Frau', 'Herr', 'Divers'] }; + +executeSnapshotTests( + KolComboboxTag, + [KolCombobox], + [ + { ...baseObj }, + { ...baseObj, _hideError: false }, + { ...baseObj, _hideError: true }, + { + ...baseObj, + _icons: { left: { icon: 'codicon codicon-arrow-left', }, @@ -30,14 +23,11 @@ executeTests( icon: 'codicon codicon-arrow-right', }, }, - ], - _required: [false, true], - _touched: [false, true], - _label: ['Label'], - }, - getComboboxHtml, - { - execMode: 'default', // ready - needTimers: true, - }, + }, + { ...baseObj, _required: false }, + { ...baseObj, _required: true }, + { ...baseObj, _touched: false }, + { ...baseObj, _touched: true }, + { ...baseObj, _disabled: true }, + ], ); diff --git a/packages/components/src/components/details/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/details/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..0ab64f094b --- /dev/null +++ b/packages/components/src/components/details/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,229 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-details should render with _label="Zusammenfassung" _disabled=false _open=false 1`] = ` + + + +`; + +exports[`kol-details should render with _label="Zusammenfassung" _disabled=false _open=true 1`] = ` + + + +`; + +exports[`kol-details should render with _label="Zusammenfassung" _disabled=true _open=false 1`] = ` + + + +`; + +exports[`kol-details should render with _label="Zusammenfassung" _disabled=true _open=true 1`] = ` + + + +`; + +exports[`kol-details should render with _label="Zusammenfassung" _level=0 1`] = ` + + + +`; + +exports[`kol-details should render with _label="Zusammenfassung" _level=1 1`] = ` + + + +`; + +exports[`kol-details should render with _label="Zusammenfassung" _level=2 1`] = ` + + + +`; + +exports[`kol-details should render with _label="Zusammenfassung" _level=3 1`] = ` + + + +`; + +exports[`kol-details should render with _label="Zusammenfassung" _level=4 1`] = ` + + + +`; + +exports[`kol-details should render with _label="Zusammenfassung" _level=5 1`] = ` + + + +`; + +exports[`kol-details should render with _label="Zusammenfassung" _level=6 1`] = ` + + + +`; + +exports[`kol-details should render with _label="Zusammenfassung" 1`] = ` + + + +`; diff --git a/packages/components/src/components/details/test/html.mock.ts b/packages/components/src/components/details/test/html.mock.ts deleted file mode 100644 index d27cd78a12..0000000000 --- a/packages/components/src/components/details/test/html.mock.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { mixMembers } from 'stencil-awesome-test'; - -import type { DetailsProps } from '../../../schema'; -import { KolButtonWcTag, KolHeadingWcTag } from '../../../core/component-names'; - -export const getDetailsHtml = (props: DetailsProps): string => { - props = mixMembers( - { - _label: '', // ⚠ required - }, - props, - ); - - return ` - -
    - <${KolHeadingWcTag} _label="" _level="${1}" class="collapsible__heading details__heading"> - <${KolButtonWcTag} - class="collapsible__heading-button details__heading-button" - slot="expert" - _ariaControls="nonce-control" - ${props._open ? '_ariaExpanded=""' : ''} - ${props._disabled ? '_disabled=""' : ''} - _icons="codicon codicon-chevron-right" - _label="${props._label}" - > - -
    -
    -
    -
    -
    -
    -
    -`; -}; diff --git a/packages/components/src/components/details/test/snapshot.spec.tsx b/packages/components/src/components/details/test/snapshot.spec.tsx index 25b9ee78e1..51de54efd9 100644 --- a/packages/components/src/components/details/test/snapshot.spec.tsx +++ b/packages/components/src/components/details/test/snapshot.spec.tsx @@ -1,30 +1,20 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolDetailsTag } from '@component-names'; +import type { DetailsProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; +import { KolDetails } from '../shadow'; -import { getDetailsHtml } from './html.mock'; +executeSnapshotTests( + KolDetailsTag, + [KolDetails], + [ + { _label: 'Zusammenfassung' }, -import type { SpecPage } from '@stencil/core/testing'; -import type { DetailsProps } from '../../../schema'; -import { KolDetails } from '../shadow'; + { _label: 'Zusammenfassung', _disabled: true, _open: false }, + { _label: 'Zusammenfassung', _disabled: true, _open: true }, + { _label: 'Zusammenfassung', _disabled: false, _open: false }, + { _label: 'Zusammenfassung', _disabled: false, _open: true }, -executeTests( - 'Details', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolDetails], - template: () => , - }); - return page; - }, - { - _disabled: [true, false], - _label: ['Zusammenfassung'], - _open: [false, true], - }, - getDetailsHtml, - { - execMode: 'default', // ready - }, + ...[0, 1, 2, 3, 4, 5, 6].map((_level) => ({ _label: 'Zusammenfassung', _level }) as DetailsProps), + ], ); diff --git a/packages/components/src/components/drawer/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/drawer/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..82e9aed877 --- /dev/null +++ b/packages/components/src/components/drawer/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,169 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-drawer should render with _label="Label" _modal=false _open=false 1`] = ` + + + +`; + +exports[`kol-drawer should render with _label="Label" _modal=false _open=true _variant="bottom" 1`] = ` + + + +`; + +exports[`kol-drawer should render with _label="Label" _modal=false _open=true _variant="left" 1`] = ` + + + +`; + +exports[`kol-drawer should render with _label="Label" _modal=false _open=true _variant="right" 1`] = ` + + + +`; + +exports[`kol-drawer should render with _label="Label" _modal=false _open=true _variant="top" 1`] = ` + + + +`; + +exports[`kol-drawer should render with _label="Label" _modal=true _open=false 1`] = ` + + + +`; + +exports[`kol-drawer should render with _label="Label" _modal=true _open=true _variant="bottom" 1`] = ` + + + +`; + +exports[`kol-drawer should render with _label="Label" _modal=true _open=true _variant="left" 1`] = ` + + + +`; + +exports[`kol-drawer should render with _label="Label" _modal=true _open=true _variant="right" 1`] = ` + + + +`; + +exports[`kol-drawer should render with _label="Label" _modal=true _open=true _variant="top" 1`] = ` + + + +`; + +exports[`kol-drawer should render with _label="Label" _open=false 1`] = ` + + + +`; + +exports[`kol-drawer should render with _label="Label" 1`] = ` + + + +`; diff --git a/packages/components/src/components/drawer/test/html.mock.ts b/packages/components/src/components/drawer/test/html.mock.ts deleted file mode 100644 index 764349a19f..0000000000 --- a/packages/components/src/components/drawer/test/html.mock.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type { DrawerProps, DrawerStates } from '../../../schema'; -import { mixMembers } from 'stencil-awesome-test'; - -export const getDrawerHtml = (props: DrawerProps): string => { - const state = mixMembers( - { - _label: '', // ⚠ required - _open: false, - _modal: false, - _align: 'top', - }, - props, - ); - const align = state._align; - const isOpen = state._open; - return ` - - - -
    -
    - -
    -
    -
    -
    -
    - `; -}; diff --git a/packages/components/src/components/drawer/test/snapshot.spec.tsx b/packages/components/src/components/drawer/test/snapshot.spec.tsx index 0fec7718a1..08853435a9 100644 --- a/packages/components/src/components/drawer/test/snapshot.spec.tsx +++ b/packages/components/src/components/drawer/test/snapshot.spec.tsx @@ -1,28 +1,28 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolDrawerTag } from '@component-names'; +import type { DrawerProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; +import { KolDrawer } from '../shadow'; -import { getDrawerHtml } from './html.mock'; +function getVariantsByModalMode(modal: boolean) { + return ['top', 'right', 'bottom', 'left'].map((variant) => ({ + _label: 'Label', + _modal: modal, + _open: true, + _variant: variant, + })); +} -import type { SpecPage } from '@stencil/core/testing'; -import type { DrawerProps } from '../../../schema'; -import { KolDrawer } from '../shadow'; +executeSnapshotTests( + KolDrawerTag, + [KolDrawer], + [ + { _label: 'Label' }, + { _label: 'Label', _open: false }, + { _label: 'Label', _modal: false, _open: false }, + { _label: 'Label', _modal: true, _open: false }, -executeTests( - 'Drawer', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolDrawer], - template: () => , - }); - return page; - }, - { - _label: ['Label'], - _open: [true, false], - _modal: [true, false], - _align: ['top', 'right', 'bottom', 'left'], - }, - getDrawerHtml, + ...getVariantsByModalMode(false), + ...getVariantsByModalMode(true), + ], ); diff --git a/packages/components/src/components/form/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/form/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..fcc9e8d5e6 --- /dev/null +++ b/packages/components/src/components/form/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,16 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-form should render with _requiredText="Pflichtfeld" 1`] = ` + + + +`; diff --git a/packages/components/src/components/form/test/html.mock.ts b/packages/components/src/components/form/test/html.mock.ts deleted file mode 100644 index 48b78923cd..0000000000 --- a/packages/components/src/components/form/test/html.mock.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { mixMembers } from 'stencil-awesome-test'; - -import type { FormProps } from '../../../schema'; -export const getFormHtml = (props: FormProps): string => { - props = mixMembers({ ...props }, props); - return ` - -
    -

    -

    ${ - typeof props._requiredText === 'string' ? props._requiredText : 'Formular-Felder, die mit einem Sternchen (*) gekennzeichnet sind, sind Pflichtangaben.' - }
    -

    - - -
    -
    `; -}; diff --git a/packages/components/src/components/form/test/snapshot.spec.tsx b/packages/components/src/components/form/test/snapshot.spec.tsx index a77b018433..3b8a260b67 100644 --- a/packages/components/src/components/form/test/snapshot.spec.tsx +++ b/packages/components/src/components/form/test/snapshot.spec.tsx @@ -1,28 +1,7 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolFormTag } from '@component-names'; +import type { FormProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getFormHtml } from './html.mock'; - -import type { FormProps } from '../../../schema'; -import type { SpecPage } from '@stencil/core/testing'; import { KolForm } from '../shadow'; -executeTests( - 'Form', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolForm], - template: () => , - }); - return page; - }, - { - _requiredText: ['Pflichtfeld'], - }, - getFormHtml, - { - execMode: 'skip', - }, -); +executeSnapshotTests(KolFormTag, [KolForm], [{ _requiredText: 'Pflichtfeld' }]); diff --git a/packages/components/src/components/heading/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/heading/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..225645243f --- /dev/null +++ b/packages/components/src/components/heading/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,151 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-heading should render with _label="Headline" _level=0 1`] = ` + + + +`; + +exports[`kol-heading should render with _label="Headline" _level=1 1`] = ` + + + +`; + +exports[`kol-heading should render with _label="Headline" _level=2 1`] = ` + + + +`; + +exports[`kol-heading should render with _label="Headline" _level=3 1`] = ` + + + +`; + +exports[`kol-heading should render with _label="Headline" _level=4 1`] = ` + + + +`; + +exports[`kol-heading should render with _label="Headline" _level=5 1`] = ` + + + +`; + +exports[`kol-heading should render with _label="Headline" _level=6 1`] = ` + + + +`; + +exports[`kol-heading should render with _label="Headline" _variant="h1" 1`] = ` + + + +`; + +exports[`kol-heading should render with _label="Headline" _variant="h2" 1`] = ` + + + +`; + +exports[`kol-heading should render with _label="Headline" _variant="h3" 1`] = ` + + + +`; + +exports[`kol-heading should render with _label="Headline" _variant="h4" 1`] = ` + + + +`; + +exports[`kol-heading should render with _label="Headline" _variant="h5" 1`] = ` + + + +`; + +exports[`kol-heading should render with _label="Headline" _variant="h6" 1`] = ` + + + +`; + +exports[`kol-heading should render with _label="Headline" _variant="strong" 1`] = ` + + + +`; + +exports[`kol-heading should render with _label="Headline" 1`] = ` + + + +`; diff --git a/packages/components/src/components/heading/test/html.mock.ts b/packages/components/src/components/heading/test/html.mock.ts deleted file mode 100644 index 7dde2a5995..0000000000 --- a/packages/components/src/components/heading/test/html.mock.ts +++ /dev/null @@ -1,42 +0,0 @@ -import type { HeadingProps, HeadingStates } from '../../../schema'; -import { mixMembers } from 'stencil-awesome-test'; - -export const getHeadingWcHtml = ( - props: HeadingProps, - slots: { - expert?: string; - } = {}, - additionalAttrs = '', -): string => { - const state = mixMembers( - { - _label: '', // ⚠ required - _level: 1, - }, - props, - ); - const tag = state._level === 0 ? 'strong' : `h${state._level || 1}`; - - return ` - - <${tag} class="headline headline-${props._variant || tag}"> - ${state._label} - ${slots.expert !== undefined ? slots.expert : ''} - - `; -}; - -export const getHeadingHtml = ( - props: HeadingProps, - slots: { - expert?: string; - } = {}, -): string => { - return ` - - - ${getHeadingWcHtml(props, {}, ` class="kol-heading kol-heading-wc"`)} - - ${slots.expert !== undefined ? slots.expert : ''} -`; -}; diff --git a/packages/components/src/components/heading/test/snapshot.spec.tsx b/packages/components/src/components/heading/test/snapshot.spec.tsx index 07335d1c7d..da2c20510b 100644 --- a/packages/components/src/components/heading/test/snapshot.spec.tsx +++ b/packages/components/src/components/heading/test/snapshot.spec.tsx @@ -1,32 +1,15 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolHeadingTag } from '@component-names'; +import type { HeadingProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getHeadingHtml } from './html.mock'; - -import type { HeadingProps } from '../../../schema'; -import type { SpecPage } from '@stencil/core/testing'; import { KolHeading } from '../shadow'; -import { KolHeadingWc } from '../component'; -executeTests( - 'Heading', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolHeading, KolHeadingWc], - template: () => , - }); - return page; - }, - { - _label: ['Headline'], - _level: [1, 2, 3, 4, 5, 6], - _variant: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'strong'], - // _secondaryHeadline: ['Secondary Headline'], - }, - getHeadingHtml, - { - execMode: 'default', // ready - }, +executeSnapshotTests( + KolHeadingTag, + [KolHeading], + [ + { _label: 'Headline' }, + ...[0, 1, 2, 3, 4, 5, 6].map((_level) => ({ _label: 'Headline', _level }) as HeadingProps), + ...['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'strong'].map((_variant) => ({ _label: 'Headline', _variant }) as HeadingProps), + ], ); diff --git a/packages/components/src/components/icon/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/icon/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..f572b20139 --- /dev/null +++ b/packages/components/src/components/icon/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,9 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-icon should render with _label="Aria-Label" _icons="codicon codicon-home" 1`] = ` + + + +`; diff --git a/packages/components/src/components/icon/test/html.mock.ts b/packages/components/src/components/icon/test/html.mock.ts deleted file mode 100644 index d67645a349..0000000000 --- a/packages/components/src/components/icon/test/html.mock.ts +++ /dev/null @@ -1,58 +0,0 @@ -import type { IconProps, IconStates } from '../../../schema'; -import { readFileSync } from 'fs'; -import { render } from 'mustache'; -import path from 'path'; -import pug from 'pug'; -import { mixMembers } from 'stencil-awesome-test'; -import { twig } from 'twig'; - -const getState = (props: IconProps): IconStates => - mixMembers( - { - _icons: 'codicon codicon-home', - _label: '', - }, - props, - ); - -const getIconHtmlTwig = (props: IconProps, additionalAttrs = ''): string => { - const state = getState(props); - const context = { additionalAttrs, ...state, mode: 'csr' }; - - return twig({ path: path.join(__dirname, 'icon.twig'), async: false }).render(context); -}; - -/* eslint-disable @typescript-eslint/no-unused-vars,@typescript-eslint/ban-ts-comment */ -// @ts-ignore -const getIconHtmlMustache = (props: IconProps, additionalAttrs = ''): string => { - const state = getState(props); - const template = readFileSync(path.join(__dirname, 'icon.mustache'), { encoding: 'utf-8' }); - - return render(template, { - additionalAttrs, - ...state, - csrMode: true, - ssrMode: false, - }); -}; - -// @ts-ignore -const getIconHtmlPug = (props: IconProps, additionalAttrs = ''): string => { - const compiledFunction = pug.compileFile(path.join(__dirname, 'icon.pug')); - const state = getState(props); - - // eslint-disable-next-line @typescript-eslint/no-unsafe-call - return compiledFunction({ - additionalAttrs, - mode: 'csr', - ...state, - }); -}; - -/* eslint-enable @typescript-eslint/no-unused-vars,@typescript-eslint/ban-ts-comment */ - -export const getIconHtml = (props: IconProps, additionalAttrs = ` class="kol-icon" `): string => { - return getIconHtmlTwig(props, additionalAttrs); - // return getIconHtmlMustache(props, additionalAttrs); - // return getIconHtmlPug(props, additionalAttrs); -}; diff --git a/packages/components/src/components/icon/test/snapshot.spec.tsx b/packages/components/src/components/icon/test/snapshot.spec.tsx index 4dd4debbec..f6d6626874 100644 --- a/packages/components/src/components/icon/test/snapshot.spec.tsx +++ b/packages/components/src/components/icon/test/snapshot.spec.tsx @@ -1,29 +1,7 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolIconTag } from '@component-names'; +import type { IconProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getIconHtml } from './html.mock'; - -import type { SpecPage } from '@stencil/core/testing'; -import type { IconProps } from '../../../schema'; import { KolIcon } from '../shadow'; -executeTests( - 'Icon', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolIcon], - template: () => , - }); - return page; - }, - { - _label: ['Aria-Label'], - _icons: ['codicon codicon-home'], - }, - getIconHtml, - { - execMode: 'default', // ready - }, -); +executeSnapshotTests(KolIconTag, [KolIcon], [{ _label: 'Aria-Label', _icons: 'codicon codicon-home' }]); diff --git a/packages/components/src/components/image/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/image/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..8cb851befc --- /dev/null +++ b/packages/components/src/components/image/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,33 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-image should render with _alt="somedescription" _loading="eager" _src="https://some-url.tld/images/awesome.jpg" _sizes="(max-width: 710px) 120px, (max-width: 991px) 193px, 278px" _srcset="https://some-url.tld/images/awesome.avif" 1`] = ` + + + +`; + +exports[`kol-image should render with _alt="somedescription" _loading="eager" _src="https://some-url.tld/images/awesome.jpg" 1`] = ` + + + +`; + +exports[`kol-image should render with _alt="somedescription" _loading="lazy" _src="https://some-url.tld/images/awesome.jpg" 1`] = ` + + + +`; + +exports[`kol-image should render with _alt="somedescription" _src="something" 1`] = ` + + + +`; diff --git a/packages/components/src/components/image/test/snapshot.spec.tsx b/packages/components/src/components/image/test/snapshot.spec.tsx index 1749d83974..37248abd77 100644 --- a/packages/components/src/components/image/test/snapshot.spec.tsx +++ b/packages/components/src/components/image/test/snapshot.spec.tsx @@ -1,45 +1,22 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolImageTag } from '@component-names'; +import type { ImageProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getImageHtml } from './html.mock'; - -import type { ImageProps } from '../../../schema'; -import type { SpecPage } from '@stencil/core/testing'; import { KolImage } from '../shadow'; -executeTests( - 'Image', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolImage], - template: () => , - }); - return page; - }, - { - _alt: ['somedescription'], - _src: ['something'], - }, - getImageHtml, -); - -executeTests( - 'Image', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolImage], - template: () => , - }); - return page; - }, - { - _alt: ['somedescription'], - _loading: ['eager'], - _sizes: ['(max-width: 710px) 120px, (max-width: 991px) 193px, 278px'], - _src: ['https://some-url.tld/images/awesome.jpg'], - _srcset: ['https://some-url.tld/images/awesome.avif, https://some-url.tld/images/awesome.webp'], - }, - getImageHtml, +executeSnapshotTests( + KolImageTag, + [KolImage], + [ + { _alt: 'somedescription', _src: 'something' }, + { _alt: 'somedescription', _loading: 'lazy', _src: 'https://some-url.tld/images/awesome.jpg' }, + { _alt: 'somedescription', _loading: 'eager', _src: 'https://some-url.tld/images/awesome.jpg' }, + { + _alt: 'somedescription', + _loading: 'eager', + _src: 'https://some-url.tld/images/awesome.jpg', + _sizes: '(max-width: 710px) 120px, (max-width: 991px) 193px, 278px', + _srcset: 'https://some-url.tld/images/awesome.avif', + }, + ], ); diff --git a/packages/components/src/components/link-button/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/link-button/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..fc91882b01 --- /dev/null +++ b/packages/components/src/components/link-button/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,71 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-link-button should render with _href="https://google.de" _icons="codicon codicon-home" _label="Label" _target="self" _tooltipAlign="bottom" 1`] = ` + + + +`; + +exports[`kol-link-button should render with _href="https://google.de" _icons="codicon codicon-home" _label="Label" _target="self" _tooltipAlign="left" 1`] = ` + + + +`; + +exports[`kol-link-button should render with _href="https://google.de" _icons="codicon codicon-home" _label="Label" _target="self" _tooltipAlign="right" 1`] = ` + + + +`; + +exports[`kol-link-button should render with _href="https://google.de" _icons="codicon codicon-home" _label="Label" _target="self" _tooltipAlign="top" _hideLabel=true 1`] = ` + + + +`; + +exports[`kol-link-button should render with _href="https://google.de" _icons="codicon codicon-home" _label="Label" _target="self" _tooltipAlign="top" 1`] = ` + + + +`; + +exports[`kol-link-button should render with _href="https://google.de" _icons="codicon codicon-home" _label="Label" _target="self" 1`] = ` + + + +`; + +exports[`kol-link-button should render with _label="Label" _href="" _download="download-file.zip" _target="blank" 1`] = ` + + + +`; diff --git a/packages/components/src/components/link-button/test/html.mock.ts b/packages/components/src/components/link-button/test/html.mock.ts deleted file mode 100644 index dcd6285104..0000000000 --- a/packages/components/src/components/link-button/test/html.mock.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { LinkButtonProps } from '../../../schema'; -import { KolLinkWcTag } from '../../../core/component-names'; - -export const getLinkButtonHtml = (props: LinkButtonProps): string => { - return ` - - - <${KolLinkWcTag} - ${props._href ? `_href="${props._href}"` : ''} - ${props._label ? `_label="${props._label}"` : ''} - ${typeof props._icons === 'string' ? `_icons="${props._icons}"` : ''} - ${props._target ? `_target="${props._target}"` : ''} - ${typeof props._download === 'string' ? ` _download="${props._download}"` : ''} - ${props._hideLabel ? `_hidelabel=""` : ''} - ${props._tooltipAlign ? `_tooltipalign="${props._tooltipAlign}"` : '_tooltipalign="right"'} - ${props._disabled ? `_disabled=""` : ''} - _role="button" - class="button normal" - > - - - -`; -}; diff --git a/packages/components/src/components/link-button/test/snapshot.spec.tsx b/packages/components/src/components/link-button/test/snapshot.spec.tsx index 72418ec355..c3c0fa277e 100644 --- a/packages/components/src/components/link-button/test/snapshot.spec.tsx +++ b/packages/components/src/components/link-button/test/snapshot.spec.tsx @@ -1,35 +1,32 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolLinkButtonTag } from '@component-names'; +import type { LinkButtonProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; +import { KolLinkButton } from '../shadow'; -import { getLinkButtonHtml } from './html.mock'; +// _disabled: [true, false], +// _href: ['https://google.de'], +// _icons: ['codicon codicon-home'], +// _hideLabel: [false, true], +// _label: ['Label'], +// _target: ['_self', '_blank', 'egal'], +// _tooltipAlign: ['top', 'right', 'bottom', 'left'], +// _download: ['', 'download-file.zip'], -import type { SpecPage } from '@stencil/core/testing'; -import type { LinkButtonProps } from '../../../schema'; -import { KolLinkButton } from '../shadow'; +const baseObj = { _href: 'https://google.de', _icons: 'codicon codicon-home', _label: 'Label', _target: 'self' }; + +executeSnapshotTests( + KolLinkButtonTag, + [KolLinkButton], + [ + { ...baseObj }, + { ...baseObj, _tooltipAlign: 'top' }, + { ...baseObj, _tooltipAlign: 'left' }, + { ...baseObj, _tooltipAlign: 'right' }, + { ...baseObj, _tooltipAlign: 'bottom' }, + + { ...baseObj, _tooltipAlign: 'top', _hideLabel: true }, -executeTests( - 'LinkButton', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolLinkButton], - template: () => , - }); - return page; - }, - { - _label: ['Label'], - _href: ['https://google.de'], - _icons: ['codicon codicon-squirrel'], - _disabled: [true, false], - _hideLabel: [false, true], - _target: ['_self', '_blank', 'egal'], - _tooltipAlign: ['top', 'right', 'bottom', 'left'], - _download: ['', 'download-file.zip'], - }, - getLinkButtonHtml, - { - execMode: 'default', // ready - }, + { _label: 'Label', _href: '', _download: 'download-file.zip', _target: 'blank' }, + ], ); diff --git a/packages/components/src/components/link-group/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/link-group/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..d510a22161 --- /dev/null +++ b/packages/components/src/components/link-group/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,73 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-link-group should render with _label="Primary" _links=[{"_label":"Link 1","_href":"#"},{"_label":"Link 2","_href":"#"},{"_label":"Link 3","_href":"#"}] _listStyleType="square" 1`] = ` + + + +`; + +exports[`kol-link-group should render with _label="Primary" _links=[{"_label":"Link 1","_href":"#"},{"_label":"Link 2","_href":"#"},{"_label":"Link 3","_href":"#"}] _orientation="horizontal" 1`] = ` + + + +`; + +exports[`kol-link-group should render with _label="Primary" _links=[{"_label":"Link 1","_href":"#"},{"_label":"Link 2","_href":"#"},{"_label":"Link 3","_href":"#"}] _orientation="vertical" 1`] = ` + + + +`; + +exports[`kol-link-group should render with _label="Primary" _links=[{"_label":"Link 1","_href":"#"},{"_label":"Link 2","_href":"#"},{"_label":"Link 3","_href":"#"}] 1`] = ` + + + +`; diff --git a/packages/components/src/components/link-group/test/html.mock.ts b/packages/components/src/components/link-group/test/html.mock.ts deleted file mode 100644 index b3a740c0f2..0000000000 --- a/packages/components/src/components/link-group/test/html.mock.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { mixMembers } from 'stencil-awesome-test'; - -import type { LinkGroupProps } from '../../../schema'; - -export const getLinkGroupHtml = (props: LinkGroupProps): string => { - props = mixMembers( - { - _listStyleType: 'disc', - _links: [], - _orientation: 'vertical', - }, - props, - ); - return ` - - -
      -
      -
      `; -}; diff --git a/packages/components/src/components/link-group/test/snapshot.spec.tsx b/packages/components/src/components/link-group/test/snapshot.spec.tsx index 61df1ab678..bb3f213fa6 100644 --- a/packages/components/src/components/link-group/test/snapshot.spec.tsx +++ b/packages/components/src/components/link-group/test/snapshot.spec.tsx @@ -1,34 +1,20 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolLinkGroupTag } from '@component-names'; +import type { LinkGroupProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getLinkGroupHtml } from './html.mock'; - -import type { SpecPage } from '@stencil/core/testing'; -import type { LinkGroupProps } from '../../../schema'; import { KolLinkGroup } from '../shadow'; -executeTests( - 'LinkGroup', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolLinkGroup], - template: () => , - }); - return page; - }, - { - _label: ['Primary', 'Danger'], - _links: [ - { _label: 'Link 1', _href: '#' }, - { _label: 'Link 2', _href: '#' }, - { _label: 'Link 3', _href: '#' }, - ], - _orientation: ['vertical', 'horizontal'], - }, - (props) => getLinkGroupHtml(props), - { - execMode: 'default', // ready - }, +const baseObj: LinkGroupProps = { + _label: 'Primary', + _links: [ + { _label: 'Link 1', _href: '#' }, + { _label: 'Link 2', _href: '#' }, + { _label: 'Link 3', _href: '#' }, + ], +}; + +executeSnapshotTests( + KolLinkGroupTag, + [KolLinkGroup], + [{ ...baseObj }, { ...baseObj, _orientation: 'horizontal' }, { ...baseObj, _orientation: 'vertical' }, { ...baseObj, _listStyleType: 'square' }], ); diff --git a/packages/components/src/components/link/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/link/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..1703b36870 --- /dev/null +++ b/packages/components/src/components/link/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,120 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-link should render with _href="https://google.de" _icons="codicon codicon-home" _label="Label" _target="self" _tooltipAlign="bottom" 1`] = ` + + + +`; + +exports[`kol-link should render with _href="https://google.de" _icons="codicon codicon-home" _label="Label" _target="self" _tooltipAlign="left" 1`] = ` + + + +`; + +exports[`kol-link should render with _href="https://google.de" _icons="codicon codicon-home" _label="Label" _target="self" _tooltipAlign="right" 1`] = ` + + + +`; + +exports[`kol-link should render with _href="https://google.de" _icons="codicon codicon-home" _label="Label" _target="self" _tooltipAlign="top" _hideLabel=true 1`] = ` + + + +`; + +exports[`kol-link should render with _href="https://google.de" _icons="codicon codicon-home" _label="Label" _target="self" _tooltipAlign="top" 1`] = ` + + + +`; + +exports[`kol-link should render with _href="https://google.de" _icons="codicon codicon-home" _label="Label" _target="self" 1`] = ` + + + +`; + +exports[`kol-link should render with _label="Label" _href="" _download="download-file.zip" _target="blank" 1`] = ` + + + +`; diff --git a/packages/components/src/components/link/test/html.mock.ts b/packages/components/src/components/link/test/html.mock.ts deleted file mode 100644 index 6c8ffc71db..0000000000 --- a/packages/components/src/components/link/test/html.mock.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { mixMembers } from 'stencil-awesome-test'; - -import { showExpertSlot } from '../../../schema'; - -import type { LinkProps, LinkStates } from '../../../schema'; -import clsx from 'clsx'; -import { translate } from '../../../i18n'; -import { KolSpanWcTag, KolIconTag, KolTooltipWcTag } from '../../../core/component-names'; -export const getLinkHtml = (props: LinkProps, innerHTML = ''): string => { - const state = mixMembers( - { - _ariaCurrentValue: 'page', - _href: '', // ⚠ required - _icons: {}, - }, - props, - ); - const hasExpertSlot = showExpertSlot(state._label); - const isExternal = typeof state._target === 'string' && state._target !== '_self'; - - const classNames = clsx({ - disabled: state._disabled, - 'hide-label': state._hideLabel, - 'external-link': isExternal, - }); - - return ` - - - - - <${KolSpanWcTag} - ${state._hideLabel ? '_hidelabel=""' : ''} - _label="${state._label || state._href}" - > - - - - ${ - typeof state._target === 'string' && state._target !== '_self' - ? ` <${KolIconTag} - class="external-link-icon" - _label="${state._hideLabel ? '' : translate('kol-open-link-in-tab')}" - _icons="codicon codicon-link-external" - ${state._hideLabel ? ' aria-hidden=""' : ''} - >` - : '' - } - - <${KolTooltipWcTag} - aria-hidden="true" - ${hasExpertSlot || !state._hideLabel ? ' hidden' : ''} - _align="${state._tooltipAlign ? state._tooltipAlign : 'right'}" - _label="${state._label || state._href}" - > - - - - ${innerHTML} -`; -}; diff --git a/packages/components/src/components/link/test/snapshot.spec.tsx b/packages/components/src/components/link/test/snapshot.spec.tsx index c0a473dd03..08c46072ef 100644 --- a/packages/components/src/components/link/test/snapshot.spec.tsx +++ b/packages/components/src/components/link/test/snapshot.spec.tsx @@ -1,36 +1,33 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolLinkTag } from '@component-names'; +import type { LinkProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getLinkHtml } from './html.mock'; - -import type { SpecPage } from '@stencil/core/testing'; -import type { LinkProps } from '../../../schema'; import { KolLink } from '../shadow'; import { KolLinkWc } from '../component'; -executeTests( - 'Link', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolLink, KolLinkWc], - template: () => , - }); - return page; - }, - { - _disabled: [true, false], - _href: ['https://google.de'], - _icons: ['codicon codicon-home'], - _hideLabel: [false, true], - _label: ['Label'], - _target: ['_self', '_blank', 'egal'], - _tooltipAlign: ['top', 'right', 'bottom', 'left'], - _download: ['', 'download-file.zip'], - }, - getLinkHtml, - { - execMode: 'default', // ready - }, +// _disabled: [true, false], +// _href: ['https://google.de'], +// _icons: ['codicon codicon-home'], +// _hideLabel: [false, true], +// _label: ['Label'], +// _target: ['_self', '_blank', 'egal'], +// _tooltipAlign: ['top', 'right', 'bottom', 'left'], +// _download: ['', 'download-file.zip'], + +const baseObj = { _href: 'https://google.de', _icons: 'codicon codicon-home', _label: 'Label', _target: 'self' }; + +executeSnapshotTests( + KolLinkTag, + [KolLink, KolLinkWc], + [ + { ...baseObj }, + { ...baseObj, _tooltipAlign: 'top' }, + { ...baseObj, _tooltipAlign: 'left' }, + { ...baseObj, _tooltipAlign: 'right' }, + { ...baseObj, _tooltipAlign: 'bottom' }, + + { ...baseObj, _tooltipAlign: 'top', _hideLabel: true }, + + { _label: 'Label', _href: '', _download: 'download-file.zip', _target: 'blank' }, + ], ); diff --git a/packages/components/src/components/modal/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/modal/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..093b906bf2 --- /dev/null +++ b/packages/components/src/components/modal/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,13 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-modal should render with _label="Label" _width="80%" 1`] = ` + + + +`; diff --git a/packages/components/src/components/modal/test/html.mock.ts b/packages/components/src/components/modal/test/html.mock.ts deleted file mode 100644 index f7127a9637..0000000000 --- a/packages/components/src/components/modal/test/html.mock.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { ModalProps } from '../../../schema'; -import { mixMembers } from 'stencil-awesome-test'; - -export const getModalHtml = (props: ModalProps): string => { - props = mixMembers( - { - _label: '', // ⚠ required - }, - props, - ); - return ` - - - -
      - -
      -
      -
      -
      `; -}; diff --git a/packages/components/src/components/modal/test/snapshot.spec.tsx b/packages/components/src/components/modal/test/snapshot.spec.tsx index 3df953f18e..934e838ab5 100644 --- a/packages/components/src/components/modal/test/snapshot.spec.tsx +++ b/packages/components/src/components/modal/test/snapshot.spec.tsx @@ -1,29 +1,7 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolModalTag } from '@component-names'; +import type { ModalProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getModalHtml } from './html.mock'; - -import type { SpecPage } from '@stencil/core/testing'; -import type { ModalProps } from '../../../schema'; import { KolModal } from '../shadow'; -executeTests( - 'Modal', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolModal], - template: () => , - }); - return page; - }, - { - _label: ['Label'], - _width: ['80%'], - }, - getModalHtml, - { - execMode: 'default', // ready - }, -); +executeSnapshotTests(KolModalTag, [KolModal], [{ _label: 'Label', _width: '80%' }]); diff --git a/packages/components/src/components/nav/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/nav/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..23bd7c3c31 --- /dev/null +++ b/packages/components/src/components/nav/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,242 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-nav should render with _label="Nav Label" _links=[{"_label":"Homepage","_href":"#"},{"_label":"Nav - aria-current","_href":"#","_active":true},{"_label":"3 Navigation point","_href":"#","_icons":"codicon codicon-home","_children":[{"_label":"3.1 Navigation point","_icons":"codicon codicon-home","_href":"#"}]},{"_label":"6 Keine eigene Seite, mit Icon","_icons":"codicon codicon-squirrel"}] _hasCompactButton=false 1`] = ` + + + +`; + +exports[`kol-nav should render with _label="Nav Label" _links=[{"_label":"Homepage","_href":"#"},{"_label":"Nav - aria-current","_href":"#","_active":true},{"_label":"3 Navigation point","_href":"#","_icons":"codicon codicon-home","_children":[{"_label":"3.1 Navigation point","_icons":"codicon codicon-home","_href":"#"}]},{"_label":"6 Keine eigene Seite, mit Icon","_icons":"codicon codicon-squirrel"}] _hasCompactButton=true 1`] = ` + + + +`; + +exports[`kol-nav should render with _label="Nav Label" _links=[{"_label":"Homepage","_href":"#"},{"_label":"Nav - aria-current","_href":"#","_active":true},{"_label":"3 Navigation point","_href":"#","_icons":"codicon codicon-home","_children":[{"_label":"3.1 Navigation point","_icons":"codicon codicon-home","_href":"#"}]},{"_label":"6 Keine eigene Seite, mit Icon","_icons":"codicon codicon-squirrel"}] _hasIconsWhenExpanded=false 1`] = ` + + + +`; + +exports[`kol-nav should render with _label="Nav Label" _links=[{"_label":"Homepage","_href":"#"},{"_label":"Nav - aria-current","_href":"#","_active":true},{"_label":"3 Navigation point","_href":"#","_icons":"codicon codicon-home","_children":[{"_label":"3.1 Navigation point","_icons":"codicon codicon-home","_href":"#"}]},{"_label":"6 Keine eigene Seite, mit Icon","_icons":"codicon codicon-squirrel"}] _hasIconsWhenExpanded=true 1`] = ` + + + +`; + +exports[`kol-nav should render with _label="Nav Label" _links=[{"_label":"Homepage","_href":"#"},{"_label":"Nav - aria-current","_href":"#","_active":true},{"_label":"3 Navigation point","_href":"#","_icons":"codicon codicon-home","_children":[{"_label":"3.1 Navigation point","_icons":"codicon codicon-home","_href":"#"}]},{"_label":"6 Keine eigene Seite, mit Icon","_icons":"codicon codicon-squirrel"}] _hideLabel=false 1`] = ` + + + +`; + +exports[`kol-nav should render with _label="Nav Label" _links=[{"_label":"Homepage","_href":"#"},{"_label":"Nav - aria-current","_href":"#","_active":true},{"_label":"3 Navigation point","_href":"#","_icons":"codicon codicon-home","_children":[{"_label":"3.1 Navigation point","_icons":"codicon codicon-home","_href":"#"}]},{"_label":"6 Keine eigene Seite, mit Icon","_icons":"codicon codicon-squirrel"}] _hideLabel=true 1`] = ` + + + +`; + +exports[`kol-nav should render with _label="Nav Label" _links=[{"_label":"Homepage","_href":"#"},{"_label":"Nav - aria-current","_href":"#","_active":true},{"_label":"3 Navigation point","_href":"#","_icons":"codicon codicon-home","_children":[{"_label":"3.1 Navigation point","_icons":"codicon codicon-home","_href":"#"}]},{"_label":"6 Keine eigene Seite, mit Icon","_icons":"codicon codicon-squirrel"}] 1`] = ` + + + +`; diff --git a/packages/components/src/components/nav/test/html.mock.ts b/packages/components/src/components/nav/test/html.mock.ts deleted file mode 100644 index 5518034ee2..0000000000 --- a/packages/components/src/components/nav/test/html.mock.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { mixMembers } from 'stencil-awesome-test'; - -import { KolButtonTag, KolButtonWcTag, KolLinkWcTag } from '../../../core/component-names'; - -import type { ButtonOrLinkOrTextWithChildrenProps, LinkProps, LinkWithChildrenProps, NavProps } from '../../../schema'; -import { translate } from '../../../i18n'; - -export const getNavHtml = (props: NavProps): string => { - props = mixMembers( - { - _collapsible: true, - _hasCompactButton: false, - _hasIconsWhenExpanded: false, - _hideLabel: false, - _label: '', // ⚠ required - _links: [], - _orientation: 'vertical', - _expandedChildren: [], - }, - props, - ); - const entryIsLink = (entryProps: ButtonOrLinkOrTextWithChildrenProps): entryProps is LinkWithChildrenProps => { - return typeof (entryProps as LinkProps)._href === 'string'; - }; - const listItems = (props._links as []) - .map((link: ButtonOrLinkOrTextWithChildrenProps) => { - const expanded = false; - const icons = - props._hasIconsWhenExpanded || props._hideLabel ? link._icons || (props._hideLabel ? 'codicon codicon-symbol-method' : undefined) : undefined; - return `
    • -
      - ${ - entryIsLink(link) - ? `<${KolLinkWcTag} ${typeof icons === 'string' ? `_icons="${icons}"` : ''} ${props._hideLabel ? '_hidelabel=""' : ''} ${link._active ? '_active=""' : ''} _href="${link._href}" _label="${link._label}" class="entry-item">` - : `<${KolButtonWcTag} ${props._hideLabel ? '_hidelabel=""' : ''} _label="${link._label}" class="entry-item" ${typeof icons === 'string' ? `_icons="${icons}"` : ''} >` - } ${ - link._children - ? `<${KolButtonWcTag} _hidelabel="" _label="${expanded ? translate('kol-nav-label-close', { placeholders: { label: link._label as string } }) : translate('kol-nav-label-open', { placeholders: { label: link._label as string } })}" class="expand-button" _icons="codicon codicon-${expanded ? 'remove' : 'add'}" >` - : '' - } -
      -
    • - `; - }) - .join(''); - return ` - - - - - -`; -}; diff --git a/packages/components/src/components/nav/test/snapshot.spec.tsx b/packages/components/src/components/nav/test/snapshot.spec.tsx index e3651b39ca..fd4a1f38f6 100644 --- a/packages/components/src/components/nav/test/snapshot.spec.tsx +++ b/packages/components/src/components/nav/test/snapshot.spec.tsx @@ -1,60 +1,52 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolNavTag } from '@component-names'; +import type { NavProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getNavHtml } from './html.mock'; - -import type { SpecPage } from '@stencil/core/testing'; -import type { NavProps } from '../../../schema'; import { KolNav } from '../shadow'; -executeTests( - 'Nav', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolNav], - template: () => , - }); - return page; - }, - { - _hasIconsWhenExpanded: [true, false], - _hasCompactButton: [true, false], - _hideLabel: [true, false], - _label: ['Nav Label', ''], - _links: [ - [ - { - _label: 'Homepage', - _href: '#', - }, +const baseObj: NavProps = { + _label: 'Nav Label', + _links: [ + { + _label: 'Homepage', + _href: '#', + }, + { + _label: 'Nav - aria-current', + _href: '#', + _active: true, + }, + { + _label: '3 Navigation point', + _href: '#', + _icons: 'codicon codicon-home', + + _children: [ { - _label: 'Nav - aria-current', + _label: '3.1 Navigation point', + _icons: 'codicon codicon-home', _href: '#', - _active: true, }, - { - _label: '3 Navigation point', - _href: '#', - _icons: 'codicon codicon-home', + ], + }, - _children: [ - { - _label: '3.1 Navigation point', - _icons: 'codicon codicon-home', - _href: '#', - }, - ], - }, + { + _label: '6 Keine eigene Seite, mit Icon', + _icons: 'codicon codicon-squirrel', + }, + ], +}; - { - _label: '6 Keine eigene Seite, mit Icon', - _icons: 'codicon codicon-squirrel', - }, - ], - ], - }, - getNavHtml, - { execMode: 'default' }, +executeSnapshotTests( + KolNavTag, + [KolNav], + [ + { ...baseObj }, + { ...baseObj, _hasIconsWhenExpanded: false }, + { ...baseObj, _hasIconsWhenExpanded: true }, + { ...baseObj, _hideLabel: false }, + { ...baseObj, _hideLabel: true }, + { ...baseObj, _hasCompactButton: false }, + { ...baseObj, _hasCompactButton: true }, + ], ); diff --git a/packages/components/src/components/pagination/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/pagination/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..2fba63807e --- /dev/null +++ b/packages/components/src/components/pagination/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,54 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-pagination should render with _label="Label" _on={} _max=0 _page=4 _hasButtons=false _siblingCount=0 1`] = ` + + + +`; + +exports[`kol-pagination should render with _label="Label" _on={} _max=2 _page=1 1`] = ` + + + +`; diff --git a/packages/components/src/components/pagination/test/html.mock.ts b/packages/components/src/components/pagination/test/html.mock.ts deleted file mode 100644 index bc0942ca63..0000000000 --- a/packages/components/src/components/pagination/test/html.mock.ts +++ /dev/null @@ -1,169 +0,0 @@ -import type { PaginationProps, PaginationStates } from '../../../schema'; -import { mixMembers } from 'stencil-awesome-test'; -import { translate } from '../../../i18n'; -import type { JSX } from '@stencil/core'; - -export const getPaginationHtml = (props: PaginationProps): string => { - const state = mixMembers( - { - _boundaryCount: 1, - _label: translate('kol-pagination'), - _hasButtons: { - first: true, - last: true, - next: true, - previous: true, - }, - _on: { - onClick: () => null, - }, - _page: 0, - _pageSize: 1, - _pageSizeOptions: [], - _siblingCount: 1, - _max: 0, - }, - props, - ); - function getUserLanguage(): string { - const userLanguage = navigator.language || 'de-DE'; - const normalizedLanguage = userLanguage.includes('-') ? userLanguage : `${userLanguage}-${userLanguage.toUpperCase()}`; - return normalizedLanguage; - } - const userLanguage = getUserLanguage(); - const NUMBER_FORMATTER = new Intl.NumberFormat(userLanguage, { - style: 'decimal', - minimumFractionDigits: 0, - maximumFractionDigits: 0, - }); - - function getUnselectedPageButton(page: number): JSX.Element { - return `
    • - - - ${translate('kol-page')} ${NUMBER_FORMATTER.format(page)} - - -
    • `; - } - - function getSelectedPageButton(page: number): JSX.Element { - return `
    • - - - ${translate('kol-page')} ${NUMBER_FORMATTER.format(page)} - - -
    • `; - } - - const count = Math.ceil(state._max / (state._pageSize ?? 1)); - if (count > 0) { - if (state._page > count) { - state._page = count; - } else if (state._page < 1) { - state._page = 1; - } - } - let ellipsis = false; - - return ` - - - - -`; -}; diff --git a/packages/components/src/components/pagination/test/snapshot.spec.tsx b/packages/components/src/components/pagination/test/snapshot.spec.tsx index 7654c17dc3..ab2ac6da69 100644 --- a/packages/components/src/components/pagination/test/snapshot.spec.tsx +++ b/packages/components/src/components/pagination/test/snapshot.spec.tsx @@ -1,34 +1,21 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolPaginationTag } from '@component-names'; +import type { PaginationProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getPaginationHtml } from './html.mock'; - -import type { SpecPage } from '@stencil/core/testing'; -import type { PaginationProps } from '../../../schema'; import { KolPagination } from '../shadow'; -executeTests( - 'Pagination', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolPagination], - template: () => , - }); - return page; - }, - { - _label: ['Label'], - _page: [4, 1], - _max: [0, 2], - _on: [{}], - _siblingCount: [0], - _hasButtons: [false], - }, - getPaginationHtml, - { - execMode: 'default', // ready - needTimers: true, - }, +// _label: ['Label'], +// _page: [4, 1], +// _max: [0, 2], +// _on: [{}], +// _siblingCount: [0], +// _hasButtons: [false], + +executeSnapshotTests( + KolPaginationTag, + [KolPagination], + [ + { _label: 'Label', _on: {}, _max: 2, _page: 1 }, + { _label: 'Label', _on: {}, _max: 0, _page: 4, _hasButtons: false, _siblingCount: 0 }, + ], ); diff --git a/packages/components/src/components/popover/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/popover/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..ad994194e2 --- /dev/null +++ b/packages/components/src/components/popover/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,37 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-popover-wc should render with _align="bottom" 1`] = ` + + + + +`; + +exports[`kol-popover-wc should render with _align="left" 1`] = ` + + + + +`; + +exports[`kol-popover-wc should render with _align="right" 1`] = ` + + + + +`; + +exports[`kol-popover-wc should render with _align="top" 1`] = ` + + + + +`; diff --git a/packages/components/src/components/popover/test/html.mock.ts b/packages/components/src/components/popover/test/html.mock.ts deleted file mode 100644 index 708b3ed105..0000000000 --- a/packages/components/src/components/popover/test/html.mock.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { PopoverProps, PopoverStates } from '../../../schema'; -import { mixMembers } from 'stencil-awesome-test'; - -export const getPopoverHtml = ( - props: PopoverProps, - slots: { - default?: string; - } = {}, -): string => { - const state = mixMembers( - { - _align: 'top', - _show: false, - _visible: false, - }, - props, - ); - return ` - - - `; -}; diff --git a/packages/components/src/components/popover/test/snapshot.spec.tsx b/packages/components/src/components/popover/test/snapshot.spec.tsx index efc94b63dd..edd540bead 100644 --- a/packages/components/src/components/popover/test/snapshot.spec.tsx +++ b/packages/components/src/components/popover/test/snapshot.spec.tsx @@ -1,28 +1,7 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolPopoverWcTag } from '@component-names'; +import type { PopoverProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getPopoverHtml } from './html.mock'; - -import type { SpecPage } from '@stencil/core/testing'; -import type { PopoverProps } from '../../../schema'; import { KolPopover } from '../component'; -executeTests( - 'Popover', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolPopover], - template: () => , - }); - return page; - }, - { - _align: ['top', 'right', 'bottom', 'left'], - }, - getPopoverHtml, - { - execMode: 'default', // ready - }, -); +executeSnapshotTests(KolPopoverWcTag, [KolPopover], [...['top', 'right', 'bottom', 'left'].map((_align) => ({ _align }) as PopoverProps)]); diff --git a/packages/components/src/components/quote/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/quote/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..a777769e24 --- /dev/null +++ b/packages/components/src/components/quote/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,61 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-quote should render with _label="Caption" _href="https://www.example.com" _quote="Text of the Quote" _variant="block" 1`] = ` + + + +`; + +exports[`kol-quote should render with _label="Caption" _href="https://www.example.com" _quote="Text of the Quote" _variant="inline" 1`] = ` + + + +`; + +exports[`kol-quote should render with _label="Caption" _href="https://www.example.com" _quote="Text of the Quote" 1`] = ` + + + +`; diff --git a/packages/components/src/components/quote/test/html.mock.ts b/packages/components/src/components/quote/test/html.mock.ts deleted file mode 100644 index f944f12166..0000000000 --- a/packages/components/src/components/quote/test/html.mock.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { mixMembers } from 'stencil-awesome-test'; - -import { showExpertSlot } from '../../../schema'; - -import { KolLinkTag } from '../../../core/component-names'; - -import type { QuoteProps, QuoteStates } from '../../../schema'; -type Slot = { - expert?: string; -}; - -export const getQuoteHtml = (props: QuoteProps, slots: Slot = {}): string => { - const state = mixMembers( - { - _href: '', // ⚠ required - _quote: '', // ⚠ required - _variant: 'inline', - }, - props, - ); - const hasExpertSlot = showExpertSlot(state._quote); // _quote instead of _caption as _label - return ` - -
      - <${state._variant === 'block' ? 'blockquote' : 'q'} cite="${state._href}"> - ${state._quote} -
      -
      -
      `; -}; diff --git a/packages/components/src/components/quote/test/snapshot.spec.tsx b/packages/components/src/components/quote/test/snapshot.spec.tsx index a295b96287..f324ca7dd4 100644 --- a/packages/components/src/components/quote/test/snapshot.spec.tsx +++ b/packages/components/src/components/quote/test/snapshot.spec.tsx @@ -1,28 +1,9 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolQuoteTag } from '@component-names'; +import type { QuoteProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getQuoteHtml } from './html.mock'; - -import type { SpecPage } from '@stencil/core/testing'; -import type { QuoteProps } from '../../../schema'; import { KolQuote } from '../shadow'; -executeTests( - 'Quote', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolQuote], - template: () => , - }); - return page; - }, - { - _label: ['Caption'], - _href: ['https://www.example.com'], - _quote: ['Text of the Quote'], - _variant: ['block', 'inline'], - }, - getQuoteHtml, -); +const baseObj = { _label: 'Caption', _href: 'https://www.example.com', _quote: 'Text of the Quote' }; + +executeSnapshotTests(KolQuoteTag, [KolQuote], [{ ...baseObj }, { ...baseObj, _variant: 'block' }, { ...baseObj, _variant: 'inline' }]); diff --git a/packages/components/src/components/skip-nav/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/skip-nav/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..1d11a4ae0a --- /dev/null +++ b/packages/components/src/components/skip-nav/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,21 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-skip-nav should render with _label="Label" _links=[{"_href":"www.google.de","_label":"Zum Anfang"},{"_href":"www.google.de","_label":"Zum Formular"},{"_href":"www.google.de","_label":"Zum Ende"}] 1`] = ` + + + +`; diff --git a/packages/components/src/components/skip-nav/test/html.mock.ts b/packages/components/src/components/skip-nav/test/html.mock.ts deleted file mode 100644 index 745c5d0815..0000000000 --- a/packages/components/src/components/skip-nav/test/html.mock.ts +++ /dev/null @@ -1,30 +0,0 @@ -import type { LinkProps, SkipNavProps, SkipNavStates } from '../../../schema'; -import { mixMembers } from 'stencil-awesome-test'; -import { KolLinkWcTag } from '../../../core/component-names'; - -export const getSkipNavHtml = (props: SkipNavProps): string => { - const state = mixMembers( - { - _label: '', // ⚠ required - _links: [], - }, - props, - ); - - return ` - - - - -`; -}; diff --git a/packages/components/src/components/skip-nav/test/snapshot.spec.tsx b/packages/components/src/components/skip-nav/test/snapshot.spec.tsx index 5caa1543fe..f28a6e0574 100644 --- a/packages/components/src/components/skip-nav/test/snapshot.spec.tsx +++ b/packages/components/src/components/skip-nav/test/snapshot.spec.tsx @@ -1,41 +1,26 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolSkipNavTag } from '@component-names'; +import type { SkipNavProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getSkipNavHtml } from './html.mock'; - -import type { SpecPage } from '@stencil/core/testing'; -import type { SkipNavProps } from '../../../schema'; import { KolSkipNav } from '../shadow'; -executeTests( - 'SkipNav', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolSkipNav], - template: () => , - }); - return page; - }, - { - _label: ['Label', ''], - _links: [ - [ - { - _label: 'Zum Anfang', - }, +executeSnapshotTests( + KolSkipNavTag, + [KolSkipNav], + [ + { + _label: 'Label', + _links: [ + { _href: 'www.google.de', _label: 'Zum Anfang' }, { + _href: 'www.google.de', _label: 'Zum Formular', }, { + _href: 'www.google.de', _label: 'Zum Ende', }, ], - ], - }, - getSkipNavHtml, - { - execMode: 'default', // ready - }, + }, + ], ); diff --git a/packages/components/src/components/spin/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/spin/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..32811933df --- /dev/null +++ b/packages/components/src/components/spin/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,20 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-spin should render with _show=false 1`] = ` + + + +`; + +exports[`kol-spin should render with _show=true 1`] = ` + + + +`; diff --git a/packages/components/src/components/spin/test/html.mock.ts b/packages/components/src/components/spin/test/html.mock.ts deleted file mode 100644 index 5232710ef3..0000000000 --- a/packages/components/src/components/spin/test/html.mock.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { SpinProps, SpinStates } from '../../../schema'; -import { mixMembers } from 'stencil-awesome-test'; - -export const getSpinHtml = (props: SpinProps): string => { - const state = mixMembers( - { - _variant: 'dot', - }, - props, - ); - return ` - - ${ - state._show === true - ? ` - - - - - ` - : '' - } - - `; -}; diff --git a/packages/components/src/components/spin/test/snapshot.spec.tsx b/packages/components/src/components/spin/test/snapshot.spec.tsx index 366d4dc74d..d582994ada 100644 --- a/packages/components/src/components/spin/test/snapshot.spec.tsx +++ b/packages/components/src/components/spin/test/snapshot.spec.tsx @@ -1,28 +1,7 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolSpinTag } from '@component-names'; +import type { SpinProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getSpinHtml } from './html.mock'; - -import type { SpinProps } from '../../../schema'; -import type { SpecPage } from '@stencil/core/testing'; import { KolSpin } from '../shadow'; -executeTests( - 'Spin', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolSpin], - template: () => , - }); - return page; - }, - { - _show: [false, true], - }, - getSpinHtml, - { - execMode: 'default', // ready - }, -); +executeSnapshotTests(KolSpinTag, [KolSpin], [{ _show: false }, { _show: true }]); diff --git a/packages/components/src/components/split-button/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/split-button/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..7ea05598ba --- /dev/null +++ b/packages/components/src/components/split-button/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,151 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-split-button should render with _label="Label" _disabled=true 1`] = ` + + + +`; + +exports[`kol-split-button should render with _label="Label" _hideLabel=true 1`] = ` + + + +`; + +exports[`kol-split-button should render with _label="Label" _icons="codicon codicon-git-pull-request" 1`] = ` + + + +`; + +exports[`kol-split-button should render with _label="Label" _name="Name" 1`] = ` + + + +`; + +exports[`kol-split-button should render with _label="Label" _variant="danger" 1`] = ` + + + +`; + +exports[`kol-split-button should render with _label="Label" _variant="ghost" 1`] = ` + + + +`; + +exports[`kol-split-button should render with _label="Label" _variant="normal" 1`] = ` + + + +`; + +exports[`kol-split-button should render with _label="Label" _variant="primary" 1`] = ` + + + +`; + +exports[`kol-split-button should render with _label="Label" _variant="secondary" 1`] = ` + + + +`; + +exports[`kol-split-button should render with _label="Label" 1`] = ` + + + +`; diff --git a/packages/components/src/components/split-button/test/snapshot.spec.tsx b/packages/components/src/components/split-button/test/snapshot.spec.tsx index fdd40c764b..67d96dabd9 100644 --- a/packages/components/src/components/split-button/test/snapshot.spec.tsx +++ b/packages/components/src/components/split-button/test/snapshot.spec.tsx @@ -1,33 +1,25 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolSplitButtonTag } from '@component-names'; +import type { SplitButtonProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getSplitButtonHtml } from './html.mock'; - -import type { SpecPage } from '@stencil/core/testing'; -import type { SplitButtonProps } from '../../../schema'; import { KolSplitButton } from '../shadow'; -executeTests( - 'SplitButton', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolSplitButton], - template: () => , - }); - return page; - }, - { - _label: ['Label'], - _hideLabel: [true, false], - _icons: ['codicon codicon-git-pull-request'], - _disabled: [true, false], - _name: ['Name', ''], - _variant: ['primary', 'secondary', 'normal', 'danger', 'ghost'], - }, - getSplitButtonHtml, - { - execMode: 'default', // ready - }, +executeSnapshotTests( + KolSplitButtonTag, + [KolSplitButton], + [ + { _label: 'Label' }, + { _label: 'Label', _hideLabel: true }, + { _label: 'Label', _disabled: true }, + { _label: 'Label', _name: 'Name' }, + { _label: 'Label', _icons: 'codicon codicon-git-pull-request' }, + + ...['primary', 'secondary', 'normal', 'danger', 'ghost'].map( + (_variant) => + ({ + _label: 'Label', + _variant, + }) as SplitButtonProps, + ), + ], ); diff --git a/packages/components/src/components/symbol/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/symbol/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..78eceef0ce --- /dev/null +++ b/packages/components/src/components/symbol/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,17 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-symbol should render with _label="Backslash" _symbol="\\\\" 1`] = ` + + + \\ + + +`; + +exports[`kol-symbol should render with _label="Slash" _symbol="/" 1`] = ` + + + / + + +`; diff --git a/packages/components/src/components/symbol/test/html.mock.ts b/packages/components/src/components/symbol/test/html.mock.ts deleted file mode 100644 index ca0fb23181..0000000000 --- a/packages/components/src/components/symbol/test/html.mock.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { mixMembers } from 'stencil-awesome-test'; - -import { translate } from '../../../i18n'; - -import type { SymbolProps } from '../../../schema'; -export const getSymbolHtml = (props: SymbolProps): string => { - props = mixMembers( - { - _label: translate('kol-warning'), - _symbol: '', // ⚠ required - }, - props, - ); - return ` - ${props._symbol} - `; -}; diff --git a/packages/components/src/components/symbol/test/snapshot.spec.tsx b/packages/components/src/components/symbol/test/snapshot.spec.tsx index 52a3754f35..02221ed53e 100644 --- a/packages/components/src/components/symbol/test/snapshot.spec.tsx +++ b/packages/components/src/components/symbol/test/snapshot.spec.tsx @@ -1,29 +1,14 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolSymbolTag } from '@component-names'; +import type { SymbolProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getSymbolHtml } from './html.mock'; - -import type { SpecPage } from '@stencil/core/testing'; -import type { SymbolProps } from '../../../schema'; import { KolSymbol } from '../component'; -executeTests( - 'Symbol', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolSymbol], - template: () => , - }); - return page; - }, - { - _label: ['Slash', 'Backslash'], - _symbol: ['/', '\\'], - }, - getSymbolHtml, - { - execMode: 'default', // ready - }, +executeSnapshotTests( + KolSymbolTag, + [KolSymbol], + [ + { _label: 'Slash', _symbol: '/' }, + { _label: 'Backslash', _symbol: '\\' }, + ], ); diff --git a/packages/components/src/components/tabs/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/tabs/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..eb3c0c8ad9 --- /dev/null +++ b/packages/components/src/components/tabs/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,17 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-tabs should render with _label="Text" _selected=1 _tabs=[{"_icons":"codicon codicon-pie-chart","_label":"Erster Tab"},{"_icons":"codicon codicon-calendar","_label":"Zweiter Tab"},{"_disabled":true,"_icons":"codicon codicon-briefcase","_label":"Deaktivierter Tab"},{"_icons":"codicon codicon-telescope","_label":"Letzter Tab"}] 1`] = ` + + + +`; diff --git a/packages/components/src/components/tabs/test/html.mock.ts b/packages/components/src/components/tabs/test/html.mock.ts deleted file mode 100644 index 08bf5750e2..0000000000 --- a/packages/components/src/components/tabs/test/html.mock.ts +++ /dev/null @@ -1,51 +0,0 @@ -import type { TabButtonProps, TabsProps, TabsStates } from '../../../schema'; -import { mixMembers } from 'stencil-awesome-test'; -import { KolButtonWcTag } from '../../../core/component-names'; - -export const getTabsHtml = (props: TabsProps): string => { - const state = mixMembers( - { - _align: 'top', - _label: '', // ⚠ required - _selected: 0, - _tabs: [], - }, - props, - ); - - return ` - - -
      -
      - - ${state._tabs - .map((button: TabButtonProps, index: number) => { - return ` - <${KolButtonWcTag} - _ariacontrols=${`tabpanel-${index}`} - ${state._selected === index ? '_ariaSelected=""' : ''} - ${state._selected === index ? '_customclass="selected"' : ''} - ${typeof button._icons === 'string' ? `_icons="${button._icons}"` : ''} - _id="${state._label.replace(/\s/g, '-')}-tab-${index}" - _label="${button._label}" - _role="tab" - _tabindex=${state._selected === index ? 0 : -1} - _value="${index}" - ${state._selected === index ? '_variant="custom"' : ''} - ${button._disabled ? '_disabled=""' : ''} - > - - `; - }) - .join('')} -
      -
      -
      -
      -
      `; -}; diff --git a/packages/components/src/components/tabs/test/snapshot.spec.tsx b/packages/components/src/components/tabs/test/snapshot.spec.tsx index 55fc5f4354..5f2bf6de7c 100644 --- a/packages/components/src/components/tabs/test/snapshot.spec.tsx +++ b/packages/components/src/components/tabs/test/snapshot.spec.tsx @@ -1,28 +1,17 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolTabsTag } from '@component-names'; +import type { TabsProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getTabsHtml } from './html.mock'; - -import type { SpecPage } from '@stencil/core/testing'; -import type { TabsProps } from '../../../schema'; import { KolTabs } from '../shadow'; -executeTests( - 'Tabs', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolTabs], - template: () => , - }); - return page; - }, - { - _label: ['Label'], - _selected: [1, 0], - _tabs: [ - [ +executeSnapshotTests( + KolTabsTag, + [KolTabs], + [ + { + _label: 'Text', + _selected: 1, + _tabs: [ { _icons: 'codicon codicon-pie-chart', _label: 'Erster Tab', @@ -41,7 +30,6 @@ executeTests( _label: 'Letzter Tab', }, ], - ], - }, - getTabsHtml, + }, + ], ); diff --git a/packages/components/src/components/toolbar/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/toolbar/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..d0b1c47937 --- /dev/null +++ b/packages/components/src/components/toolbar/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,12 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-toolbar should render with _label="Text" _items=[{"_label":"Button"},{"_href":"#","_label":"Link"}] 1`] = ` + + + +`; diff --git a/packages/components/src/components/toolbar/test/html.mock.ts b/packages/components/src/components/toolbar/test/html.mock.ts deleted file mode 100644 index 56e1b01a04..0000000000 --- a/packages/components/src/components/toolbar/test/html.mock.ts +++ /dev/null @@ -1,45 +0,0 @@ -import type { ToolbarItemPropType, ToolbarProps, ToolbarStates } from '../../../schema'; -import { mixMembers } from 'stencil-awesome-test'; -import { showExpertSlot } from '../../../schema'; -import { KolButtonTag, KolLinkTag } from '../../../core/component-names'; - -export const getToolbarHtml = (props: ToolbarProps): string => { - const state = mixMembers( - { - _label: '', // ⚠ required - _items: [], - }, - props, - ); - - return ` - - - - -`; -}; diff --git a/packages/components/src/components/toolbar/test/snapshot.spec.tsx b/packages/components/src/components/toolbar/test/snapshot.spec.tsx index f555f6639b..046ef41440 100644 --- a/packages/components/src/components/toolbar/test/snapshot.spec.tsx +++ b/packages/components/src/components/toolbar/test/snapshot.spec.tsx @@ -1,27 +1,16 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolToolbarTag } from '@component-names'; +import type { ToolbarProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getToolbarHtml } from './html.mock'; - -import type { SpecPage } from '@stencil/core/testing'; -import type { ToolbarProps } from '../../../schema'; import { KolToolbar } from '../shadow'; -executeTests( - 'Toolbar', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolToolbar], - template: () => , - }); - return page; - }, - { - _label: ['Label'], - _items: [ - [ +executeSnapshotTests( + KolToolbarTag, + [KolToolbar], + [ + { + _label: 'Text', + _items: [ { _label: 'Button', }, @@ -30,7 +19,6 @@ executeTests( _label: 'Link', }, ], - ], - }, - getToolbarHtml, + }, + ], ); diff --git a/packages/components/src/components/tooltip/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/tooltip/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..b76fc087af --- /dev/null +++ b/packages/components/src/components/tooltip/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-tooltip-wc should render with _id="id" _label="Label" _align="bottom" 1`] = ` + +
      +
      + +
      +
      +`; + +exports[`kol-tooltip-wc should render with _id="id" _label="Label" _align="left" 1`] = ` + +
      +
      + +
      +
      +`; + +exports[`kol-tooltip-wc should render with _id="id" _label="Label" _align="right" 1`] = ` + +
      +
      + +
      +
      +`; + +exports[`kol-tooltip-wc should render with _id="id" _label="Label" _align="top" 1`] = ` + +
      +
      + +
      +
      +`; + +exports[`kol-tooltip-wc should render with _id="id" _label="Label" 1`] = ` + +
      +
      + +
      +
      +`; diff --git a/packages/components/src/components/tooltip/test/html.mock.ts b/packages/components/src/components/tooltip/test/html.mock.ts deleted file mode 100644 index 25e0e80f73..0000000000 --- a/packages/components/src/components/tooltip/test/html.mock.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { mixMembers } from 'stencil-awesome-test'; - -import { KolSpanWcTag } from '../../../core/component-names'; - -import type { TooltipProps, TooltipStates } from '../../../schema'; -export const getTooltipHtml = (props: TooltipProps, additionalAttrs = ''): string => { - const state = mixMembers( - { - _align: 'top', - _label: '', // ⚠ required - }, - props, - ); - return ` - - ${ - state._label === '' - ? '' - : `
      -
      - <${KolSpanWcTag} class="tooltip-area tooltip-content" ${state._id ? `id="${state._id}"` : ''} _label="${state._label}"> -
      ` - } -`; -}; diff --git a/packages/components/src/components/tooltip/test/snapshot.spec.tsx b/packages/components/src/components/tooltip/test/snapshot.spec.tsx index e8eeec374c..fda2111925 100644 --- a/packages/components/src/components/tooltip/test/snapshot.spec.tsx +++ b/packages/components/src/components/tooltip/test/snapshot.spec.tsx @@ -1,30 +1,17 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolTooltipWcTag } from '@component-names'; +import type { TooltipProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getTooltipHtml } from './html.mock'; - -import type { TooltipProps } from '../../../schema'; -import type { SpecPage } from '@stencil/core/testing'; import { KolTooltipWc } from '../component'; -executeTests( - 'Tooltip', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolTooltipWc], - template: () => , - }); - return page; - }, - { - _align: ['top', 'right', 'bottom', 'left'], - _id: ['id'], - _label: ['Label'], - }, - getTooltipHtml, - { - execMode: 'default', // ready - }, +executeSnapshotTests( + KolTooltipWcTag, + [KolTooltipWc], + [ + { _id: 'id', _label: 'Label' }, + { _id: 'id', _label: 'Label', _align: 'top' }, + { _id: 'id', _label: 'Label', _align: 'left' }, + { _id: 'id', _label: 'Label', _align: 'right' }, + { _id: 'id', _label: 'Label', _align: 'bottom' }, + ], ); diff --git a/packages/components/src/components/tree-item/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/tree-item/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..65a2e34f27 --- /dev/null +++ b/packages/components/src/components/tree-item/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,101 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-tree-item should render with _label="Label" _href="https://google.de" _active=false 1`] = ` + + + +`; + +exports[`kol-tree-item should render with _label="Label" _href="https://google.de" _active=true 1`] = ` + + + +`; + +exports[`kol-tree-item should render with _label="Label" _href="https://google.de" _open=false 1`] = ` + + + +`; + +exports[`kol-tree-item should render with _label="Label" _href="https://google.de" _open=true 1`] = ` + + + +`; + +exports[`kol-tree-item should render with _label="Label" _href="https://google.de" 1`] = ` + + + +`; diff --git a/packages/components/src/components/tree-item/test/html.mock.ts b/packages/components/src/components/tree-item/test/html.mock.ts deleted file mode 100644 index fdf4d1ce28..0000000000 --- a/packages/components/src/components/tree-item/test/html.mock.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { mixMembers } from 'stencil-awesome-test'; - -import { KolLinkWcTag, KolTreeItemWcTag } from '../../../core/component-names'; -import type { TreeItemProps, TreeItemStates } from '../../../schema'; - -export const getTreeItemHtml = (props: TreeItemProps): string => { - const state = mixMembers( - { - _active: false, - _hasChildren: false, - _href: '', - _label: '', - _open: false, - }, - props, - ); - - return ` - - - - <${KolTreeItemWcTag} class=" kol-tree-item kol-tree-item-wc"> -
    • - <${KolLinkWcTag} - ${state._hasChildren && state._open ? `_ariaExpanded=""` : ''} - class="tree-link first-level ${state._active ? 'active' : ''}" - _label="" - _role="treeitem" - _href="${state._href}" - _tabIndex="${state._active ? 0 : -1}" - > - - ${ - state._hasChildren - ? state._open - ? ` - - - ` - : ` - + - ` - : '' - } - ${state._label} - - -
        - -
      -
    • - -
      -
      -`; -}; diff --git a/packages/components/src/components/tree-item/test/snapshot.spec.tsx b/packages/components/src/components/tree-item/test/snapshot.spec.tsx index 47bc359f68..89c74f985d 100644 --- a/packages/components/src/components/tree-item/test/snapshot.spec.tsx +++ b/packages/components/src/components/tree-item/test/snapshot.spec.tsx @@ -1,29 +1,18 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolTreeItemTag } from '@component-names'; +import type { TreeItemProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getTreeItemHtml } from './html.mock'; - -import type { SpecPage } from '@stencil/core/testing'; -import type { TreeItemProps } from '../../../schema'; import { KolTreeItem } from '../shadow'; import { KolTreeItemWc } from '../component'; -executeTests( - 'TreeItem', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolTreeItem, KolTreeItemWc], - template: () => , - }); - return page; - }, - { - _label: ['Label'], - _href: ['https://google.de'], - _open: [true, false], - _active: [true, false], - }, - getTreeItemHtml, +executeSnapshotTests( + KolTreeItemTag, + [KolTreeItem, KolTreeItemWc], + [ + { _label: 'Label', _href: 'https://google.de' }, + { _label: 'Label', _href: 'https://google.de', _open: false }, + { _label: 'Label', _href: 'https://google.de', _open: true }, + { _label: 'Label', _href: 'https://google.de', _active: false }, + { _label: 'Label', _href: 'https://google.de', _active: true }, + ], ); diff --git a/packages/components/src/components/tree/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/tree/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..2ae27421ef --- /dev/null +++ b/packages/components/src/components/tree/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,16 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-tree should render with _label="Label" 1`] = ` + + + +`; diff --git a/packages/components/src/components/tree/test/html.mock.ts b/packages/components/src/components/tree/test/html.mock.ts deleted file mode 100644 index fcd7ebcf47..0000000000 --- a/packages/components/src/components/tree/test/html.mock.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { mixMembers } from 'stencil-awesome-test'; - -import { KolTreeWcTag } from '../../../core/component-names'; -import type { TreeProps, TreeStates } from '../../../schema'; - -export const getTreeHtml = (props: TreeProps): string => { - const state = mixMembers( - { - _label: '', // ⚠ required - }, - props, - ); - - return ` - - - - <${KolTreeWcTag} class="kol-tree-wc"> - - - - -`; -}; diff --git a/packages/components/src/components/tree/test/snapshot.spec.tsx b/packages/components/src/components/tree/test/snapshot.spec.tsx index 5f162b2162..de3e3f6129 100644 --- a/packages/components/src/components/tree/test/snapshot.spec.tsx +++ b/packages/components/src/components/tree/test/snapshot.spec.tsx @@ -1,26 +1,8 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolTreeTag } from '@component-names'; +import type { TreeProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getTreeHtml } from './html.mock'; - -import type { SpecPage } from '@stencil/core/testing'; -import type { TreeProps } from '../../../schema'; import { KolTree } from '../shadow'; import { KolTreeWc } from '../component'; -executeTests( - 'Tree', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolTree, KolTreeWc], - template: () => , - }); - return page; - }, - { - _label: ['Label 1', `Label 2`], - }, - getTreeHtml, -); +executeSnapshotTests(KolTreeTag, [KolTree, KolTreeWc], [{ _label: 'Label' }]); diff --git a/packages/components/src/components/version/test/__snapshots__/snapshot.spec.tsx.snap b/packages/components/src/components/version/test/__snapshots__/snapshot.spec.tsx.snap new file mode 100644 index 0000000000..0775c2b40e --- /dev/null +++ b/packages/components/src/components/version/test/__snapshots__/snapshot.spec.tsx.snap @@ -0,0 +1,9 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`kol-version should render with _label="1.0.0" 1`] = ` + + + +`; diff --git a/packages/components/src/components/version/test/html.mock.ts b/packages/components/src/components/version/test/html.mock.ts deleted file mode 100644 index 9bf635c629..0000000000 --- a/packages/components/src/components/version/test/html.mock.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { mixMembers } from 'stencil-awesome-test'; - -import type { SpanOptions } from '../../span/test/html.mock'; -import type { VersionProps } from '../../../schema'; -import { KolBadgeTag } from '../../../core/component-names'; - -export const getVersionHtml = (props: VersionProps, options?: SpanOptions): string => { - props = mixMembers( - { - _label: '0.0.0-alpha.0', - }, - props, - ); - return ` - - - <${KolBadgeTag} - _color="#bec5c9" - _label="${props._label || '0.0.0-alpha.0'}" - > - -`; -}; diff --git a/packages/components/src/components/version/test/snapshot.spec.tsx b/packages/components/src/components/version/test/snapshot.spec.tsx index 7b4e50973d..0687b6db0a 100644 --- a/packages/components/src/components/version/test/snapshot.spec.tsx +++ b/packages/components/src/components/version/test/snapshot.spec.tsx @@ -1,28 +1,7 @@ -import { executeTests } from 'stencil-awesome-test'; +import { KolVersionTag } from '@component-names'; +import type { VersionProps } from '@schema'; +import { executeSnapshotTests } from '@testing'; -import { h } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -import { getVersionHtml } from './html.mock'; - -import type { SpecPage } from '@stencil/core/testing'; -import type { VersionProps } from '../../../schema'; import { KolVersion } from '../shadow'; -executeTests( - 'Version', - async (props): Promise => { - const page = await newSpecPage({ - components: [KolVersion], - template: () => , - }); - return page; - }, - { - _label: ['1.0.0'], - }, - (props) => getVersionHtml(props), - { - execMode: 'default', // ready - }, -); +executeSnapshotTests(KolVersionTag, [KolVersion], [{ _label: '1.0.0' }]); diff --git a/packages/components/src/core/component-names.ts b/packages/components/src/core/component-names.ts index 8922214c92..1cb84b8275 100644 --- a/packages/components/src/core/component-names.ts +++ b/packages/components/src/core/component-names.ts @@ -12,6 +12,7 @@ export let KolButtonLinkTag = 'kol-button-link' as const; export let KolButtonTag = 'kol-button' as const; export let KolButtonWcTag = 'kol-button-wc' as const; export let KolCardTag = 'kol-card' as const; +export let KolComboboxTag = 'kol-combobox' as const; export let KolDetailsTag = 'kol-details' as const; export let KolDrawerTag = 'kol-drawer' as const; export let KolFormTag = 'kol-form' as const; @@ -80,6 +81,7 @@ export const setCustomTagNames = (transformTagName: (tagName: string) => string) KolButtonTag = transformTagName(KolButtonTag as string) as 'kol-button'; KolButtonWcTag = transformTagName(KolButtonWcTag as string) as 'kol-button-wc'; KolCardTag = transformTagName(KolCardTag as string) as 'kol-card'; + KolComboboxTag = transformTagName(KolComboboxTag as string) as 'kol-combobox'; KolDetailsTag = transformTagName(KolDetailsTag as string) as 'kol-details'; KolDrawerTag = transformTagName(KolDrawerTag as string) as 'kol-drawer'; KolFormTag = transformTagName(KolFormTag as string) as 'kol-form';