@@ -6,15 +6,11 @@ import { act, fireEvent, render } from '@testing-library/react';
66
77import TestI18nProvider from '../../../lib/components/i18n/testing' ;
88import { useMobile } from '../../../lib/components/internal/hooks/use-mobile' ;
9- import PropertyFilter from '../../../lib/components/property-filter' ;
10- import {
11- FilteringOption ,
12- FilteringProperty ,
13- PropertyFilterProps ,
14- Ref ,
15- } from '../../../lib/components/property-filter/interfaces' ;
9+ import { FilteringOption , FilteringProperty , Ref } from '../../../lib/components/property-filter/interfaces' ;
10+ import PropertyFilterInternal , { PropertyFilterInternalProps } from '../../../lib/components/property-filter/internal' ;
1611import createWrapper from '../../../lib/components/test-utils/dom' ;
17- import { createDefaultProps , i18nStrings , providedI18nStrings } from './common' ;
12+ import { PropertyFilterWrapperInternal } from '../../../lib/components/test-utils/dom/property-filter' ;
13+ import { createDefaultProps , i18nStrings , i18nStringsTokenGroups , providedI18nStrings } from './common' ;
1814
1915jest . mock ( '../../../lib/components/internal/hooks/use-mobile' , ( ) => ( {
2016 ...jest . requireActual ( '../../../lib/components/internal/hooks/use-mobile' ) ,
@@ -69,20 +65,29 @@ const filteringOptions: readonly FilteringOption[] = [
6965 { propertyKey : 'default-operator' , value : 'value' } ,
7066] ;
7167
72- const defaultProps = createDefaultProps ( filteringProperties , filteringOptions ) ;
73-
74- function renderComponent ( props ?: Partial < PropertyFilterProps & { ref : React . Ref < Ref > } > , withI18nProvider = false ) {
68+ const defaultProps = {
69+ filteringOptions : [ ] ,
70+ customGroupsText : [ ] ,
71+ disableFreeTextFiltering : false ,
72+ i18nStringsTokenGroups,
73+ ...createDefaultProps ( filteringProperties , filteringOptions ) ,
74+ } ;
75+
76+ function renderComponent (
77+ props ?: Partial < PropertyFilterInternalProps & { ref : React . Ref < Ref > } > ,
78+ withI18nProvider = false
79+ ) {
7580 return withI18nProvider
7681 ? render (
7782 < TestI18nProvider messages = { providedI18nStrings } >
78- < PropertyFilter { ...defaultProps } { ...props } />
83+ < PropertyFilterInternal { ...defaultProps } { ...props } />
7984 </ TestI18nProvider >
8085 )
81- : render ( < PropertyFilter { ...defaultProps } { ...props } /> ) ;
86+ : render ( < PropertyFilterInternal { ...defaultProps } { ...props } /> ) ;
8287}
8388
8489function openEditor ( tokenIndex : number , options : { expandToViewport ?: boolean ; isMobile ?: boolean } ) {
85- const propertyFilter = createWrapper ( ) . findPropertyFilter ( ) ! ;
90+ const propertyFilter = new PropertyFilterWrapperInternal ( createWrapper ( ) . findPropertyFilter ( ) ! . getElement ( ) ) ;
8691 const token = propertyFilter . findTokens ( ) [ tokenIndex ] ;
8792 if ( token . findEditButton ( ) ) {
8893 token . findEditButton ( ) ! . click ( ) ;
@@ -96,7 +101,7 @@ function findEditor(
96101 tokenIndex : number ,
97102 { expandToViewport = false , isMobile = false } : { expandToViewport ?: boolean ; isMobile ?: boolean }
98103) {
99- const propertyFilter = createWrapper ( ) . findPropertyFilter ( ) ! ;
104+ const propertyFilter = new PropertyFilterWrapperInternal ( createWrapper ( ) . findPropertyFilter ( ) ! . getElement ( ) ) ;
100105 const editor = propertyFilter . findTokens ( ) [ tokenIndex ] . findEditorDropdown ( { expandToViewport } ) ! ;
101106 return editor
102107 ? {
@@ -467,7 +472,7 @@ describe('token editor with groups', () => {
467472 jest . mocked ( useMobile ) . mockReturnValue ( false ) ;
468473 } ) ;
469474
470- function render ( props : Partial < PropertyFilterProps > ) {
475+ function render ( props : Partial < PropertyFilterInternalProps > ) {
471476 return renderComponent ( { enableTokenGroups : true , ...props } ) ;
472477 }
473478
0 commit comments