11import { renderHook } from '@testing-library/react-hooks' ;
22import * as React from 'react' ;
3+ import type { TabsterDOMAttribute } from '@fluentui/react-tabster' ;
34
45import { useTagGroup_unstable , useTagGroupBase_unstable } from './useTagGroup' ;
56
7+ // Slot props are a discriminated union that doesn't expose `data-*` index access at
8+ // the type level; cast to a plain record for the data-attribute assertions below.
9+ type RootRecord = Record < string , unknown > ;
10+
611describe ( 'useTagGroup_unstable' , ( ) => {
712 it ( 'should default size to medium and appearance to filled' , ( ) => {
813 const ref = React . createRef < HTMLDivElement > ( ) ;
@@ -18,7 +23,7 @@ describe('useTagGroup_unstable', () => {
1823
1924 // useTagGroup_unstable wires up useArrowNavigationGroup via the base hook's
2025 // arrowNavigationProps option; Tabster's contract is a data-tabster attribute.
21- expect ( result . current . root [ 'data-tabster' ] ) . toBeDefined ( ) ;
26+ expect ( ( result . current . root as RootRecord ) [ 'data-tabster' ] ) . toBeDefined ( ) ;
2227 } ) ;
2328
2429 it ( 'should default role to toolbar' , ( ) => {
@@ -33,16 +38,15 @@ describe('useTagGroupBase_unstable', () => {
3338 it ( 'should NOT include arrow-navigation props when options omitted (true headless mode)' , ( ) => {
3439 const ref = React . createRef < HTMLDivElement > ( ) ;
3540 const { result } = renderHook ( ( ) => useTagGroupBase_unstable ( { } , ref ) ) ;
36- expect ( result . current . root [ 'data-tabster' ] ) . toBeUndefined ( ) ;
41+ expect ( ( result . current . root as RootRecord ) [ 'data-tabster' ] ) . toBeUndefined ( ) ;
3742 } ) ;
3843
3944 it ( 'should spread arrowNavigationProps option onto root when supplied' , ( ) => {
4045 const ref = React . createRef < HTMLDivElement > ( ) ;
41- const arrowNavigationProps = { 'data-arrow ' : 'group' , tabIndex : 0 } ;
46+ const arrowNavigationProps : TabsterDOMAttribute = { 'data-tabster ' : '{"mock":"value"}' } ;
4247 const { result } = renderHook ( ( ) => useTagGroupBase_unstable ( { } , ref , { arrowNavigationProps } ) ) ;
4348
44- expect ( result . current . root [ 'data-arrow' ] ) . toBe ( 'group' ) ;
45- expect ( result . current . root . tabIndex ) . toBe ( 0 ) ;
49+ expect ( ( result . current . root as RootRecord ) [ 'data-tabster' ] ) . toBe ( '{"mock":"value"}' ) ;
4650 } ) ;
4751
4852 it ( 'should call onAfterTagDismiss with the group container after a tag is dismissed' , ( ) => {
0 commit comments