diff --git a/packages/vkui/src/components/Group/Group.test.tsx b/packages/vkui/src/components/Group/Group.test.tsx index 6ff4395cff..a4a6343fa6 100644 --- a/packages/vkui/src/components/Group/Group.test.tsx +++ b/packages/vkui/src/components/Group/Group.test.tsx @@ -34,7 +34,7 @@ describe('Group', () => { isInsideModal: true, sizeX: undefined, layout: undefined, - className: classNames(styles['Group--mode-plain'], styles['Group--inside-modal']), + className: classNames(styles['Group--mode-plain'], styles['Group--mode-plain-inside-modal']), }, { mode: undefined, @@ -94,15 +94,46 @@ describe('Group', () => { }, ); - it('should force show separator', () => { - const { container } = render( - + it.each(['show', 'hide', 'auto'] as const)('should force show separator', (separator) => { + const getSeparatorEl = (container: HTMLElement) => + container.getElementsByClassName(styles['Group__separator-sibling'])[0] ?? null; + + const modeNoneResult = render( +
, ); - expect(container.getElementsByClassName(styles['Group__separator--separator'])[0]).toHaveClass( - styles['Group__separator--force'], + const modePlainResult = render( + +
+ , ); + const modeCardResult = render( + +
+ , + ); + const modeNoneSeparatorEl = getSeparatorEl(modeNoneResult.container); + const modePlainSeparatorEl = getSeparatorEl(modePlainResult.container); + const modeCardSeparatorEl = getSeparatorEl(modeCardResult.container); + + switch (separator) { + case 'show': + expect(modeNoneSeparatorEl).toHaveClass(styles['Group__separator-sibling--forced']); + expect(modePlainSeparatorEl).toHaveClass(styles['Group__separator-sibling--forced']); + expect(modeCardSeparatorEl).not.toHaveClass(styles['Group__separator-sibling--forced']); + break; + case 'auto': + expect(modeNoneSeparatorEl).not.toHaveClass(styles['Group__separator-sibling--forced']); + expect(modePlainSeparatorEl).not.toHaveClass(styles['Group__separator-sibling--forced']); + expect(modeCardSeparatorEl).not.toHaveClass(styles['Group__separator-sibling--forced']); + break; + case 'hide': + expect(modeNoneSeparatorEl).toBeNull(); + expect(modePlainSeparatorEl).toBeNull(); + expect(modeCardSeparatorEl).toBeNull(); + break; + } }); it('check DEV errors', () => { diff --git a/packages/vkui/src/components/Group/Group.tsx b/packages/vkui/src/components/Group/Group.tsx index 6cf19b309a..bc69d40e9e 100644 --- a/packages/vkui/src/components/Group/Group.tsx +++ b/packages/vkui/src/components/Group/Group.tsx @@ -12,7 +12,8 @@ import styles from './Group.module.css'; const sizeXClassNames = { none: classNames(styles['Group--sizeX-none'], 'vkuiInternalGroup--sizeX-none'), - ['compact']: styles['Group--sizeX-compact'], + regular: styles['Group--sizeX-regular'], + compact: styles['Group--sizeX-compact'], }; const stylesMode = { @@ -140,7 +141,7 @@ export const Group = ({ baseClassName={classNames( 'vkuiInternalGroup', styles['Group'], - sizeX !== 'regular' && sizeXClassNames[sizeX], + sizeXClassNames[sizeX], mode === 'plain' && isInsideModal && styles['Group--mode-plain-inside-modal'], stylesMode[mode], stylesPadding[padding],