@@ -13,8 +13,6 @@ import styles from '@patternfly/react-styles/css/components/Toolbar/toolbar';
1313
1414jest . mock ( '../../../helpers/GenerateId/GenerateId' ) ;
1515
16- jest . mock ( '../../../helpers/GenerateId/GenerateId' ) ;
17-
1816describe ( 'Toolbar' , ( ) => {
1917 it ( 'should render inset' , ( ) => {
2018 const items = (
@@ -120,122 +118,68 @@ describe('Toolbar', () => {
120118 expect ( screen . getAllByRole ( 'button' , { name : 'Clear all filters' } ) . length ) . toBe ( 1 ) ;
121119 } ) ;
122120
123- it ( 'Renders with class ${styles.modifiers.noBackground} when colorVariant="no-background"' , ( ) => {
124- const items = (
125- < Fragment >
126- < ToolbarItem > Test</ ToolbarItem >
127- < ToolbarItem > Test 2</ ToolbarItem >
128- < ToolbarItem variant = "separator" />
129- < ToolbarItem > Test 3 </ ToolbarItem >
130- </ Fragment >
131- ) ;
132-
133- render (
134- < Toolbar id = "toolbar" colorVariant = "no-background" data-testid = "Toolbar-test-no-background-id" >
135- < ToolbarContent > { items } </ ToolbarContent >
136- </ Toolbar >
137- ) ;
138-
139- expect ( screen . getByTestId ( 'Toolbar-test-no-background-id' ) ) . toHaveClass ( styles . modifiers . noBackground ) ;
140- } ) ;
141-
142- it ( 'Renders with class ${styles.modifiers.primary} when colorVariant="primary"' , ( ) => {
143- const items = (
144- < Fragment >
145- < ToolbarItem > Test</ ToolbarItem >
146- < ToolbarItem > Test 2</ ToolbarItem >
147- < ToolbarItem variant = "separator" />
148- < ToolbarItem > Test 3 </ ToolbarItem >
149- </ Fragment >
150- ) ;
151-
121+ it ( 'Renders with class when colorVariant is applied' , ( ) => {
152122 render (
153- < Toolbar id = "toolbar" colorVariant = "primary" data-testid = "Toolbar-test-primary-id" >
154- < ToolbarContent > { items } </ ToolbarContent >
155- </ Toolbar >
156- ) ;
157-
158- expect ( screen . getByTestId ( 'Toolbar-test-primary-id' ) ) . toHaveClass ( styles . modifiers . primary ) ;
159- } ) ;
160-
161- it ( 'Renders with class ${styles.modifiers.secondary} when colorVariant="secondary"' , ( ) => {
162- const items = (
163- < Fragment >
164- < ToolbarItem > Test</ ToolbarItem >
165- < ToolbarItem > Test 2</ ToolbarItem >
166- < ToolbarItem variant = "separator" />
167- < ToolbarItem > Test 3 </ ToolbarItem >
168- </ Fragment >
169- ) ;
170-
171- render (
172- < Toolbar id = "toolbar" colorVariant = "secondary" data-testid = "Toolbar-test-secondary-id" >
173- < ToolbarContent > { items } </ ToolbarContent >
123+ < Toolbar id = "toolbar" colorVariant = "primary" data-testid = "toolbar-color" >
124+ < ToolbarContent >
125+ < ToolbarItem > Test</ ToolbarItem >
126+ </ ToolbarContent >
174127 </ Toolbar >
175128 ) ;
176129
177- expect ( screen . getByTestId ( 'Toolbar-test-secondary-id' ) ) . toHaveClass ( styles . modifiers . secondary ) ;
178- } ) ;
179-
180- describe ( 'ToobarContent rowWrap' , ( ) => {
181- const bps = [ 'default' , 'sm' , 'md' , 'lg' , 'xl' , '2xl' ] ;
182-
183- describe . each ( bps ) ( `rowWrap at various breakpoints` , ( bp ) => {
184- it ( `should render with pf-m-wrap when rowWrap is set to wrap at ${ bp } ` , ( ) => {
185- render (
186- < Toolbar >
187- < ToolbarContent data-testid = "toolbarconent" rowWrap = { { [ bp ] : 'wrap' } } >
188- Test
189- </ ToolbarContent >
190- </ Toolbar >
191- ) ;
192- const bpWrapClass = bp === 'default' ? 'pf-m-wrap' : `pf-m-wrap-on-${ bp } ` ;
193-
194- expect ( screen . getByTestId ( 'toolbarconent' ) . querySelector ( 'div' ) ) . toHaveClass ( bpWrapClass ) ;
195- } ) ;
196-
197- it ( `should render with pf-m-nowrap when rowWrap is set to nowrap at ${ bp } ` , ( ) => {
198- render (
199- < ToolbarContent data-testid = "toolbarconent" rowWrap = { { [ bp ] : 'nowrap' } } >
200- Test
201- </ ToolbarContent >
202- ) ;
203- const bpNoWrapClass = bp === 'default' ? 'pf-m-nowrap' : `pf-m-nowrap-on-${ bp } ` ;
204- expect ( screen . getByTestId ( 'toolbarconent' ) . querySelector ( 'div' ) ) . toHaveClass ( bpNoWrapClass ) ;
205- } ) ;
206- } ) ;
130+ expect ( screen . getByTestId ( 'toolbar-color' ) ) . toHaveClass ( styles . modifiers . primary ) ;
207131 } ) ;
208132
209133 it ( `Renders toolbar without ${ styles . modifiers . vertical } by default` , ( ) => {
210134 render (
211135 < Toolbar data-testid = "Toolbar-test-is-not-vertical" >
212136 < ToolbarContent >
213137 < ToolbarItem > Test</ ToolbarItem >
214- < ToolbarItem > Test 2</ ToolbarItem >
215- < ToolbarItem variant = "separator" />
216- < ToolbarItem > Test 3 </ ToolbarItem >
217138 </ ToolbarContent >
218139 </ Toolbar >
219140 ) ;
220141 expect ( screen . getByTestId ( 'Toolbar-test-is-not-vertical' ) ) . not . toHaveClass ( styles . modifiers . vertical ) ;
221142 } ) ;
222143
223- it ( 'Renders with class ${styles.modifiers.vertical} when isVertical is true' , ( ) => {
224- const items = (
225- < Fragment >
226- < ToolbarItem > Test</ ToolbarItem >
227- < ToolbarItem > Test 2</ ToolbarItem >
228- < ToolbarItem variant = "separator" />
229- < ToolbarItem > Test 3 </ ToolbarItem >
230- </ Fragment >
231- ) ;
232-
144+ it ( 'Renders with vertical class when isVertical is true' , ( ) => {
233145 render (
234146 < Toolbar id = "toolbar" isVertical data-testid = "Toolbar-test-is-vertical" >
235- < ToolbarContent > { items } </ ToolbarContent >
147+ < ToolbarContent >
148+ < ToolbarItem > Test</ ToolbarItem >
149+ </ ToolbarContent >
236150 </ Toolbar >
237151 ) ;
238152
239153 expect ( screen . getByTestId ( 'Toolbar-test-is-vertical' ) ) . toHaveClass ( styles . modifiers . vertical ) ;
240154 } ) ;
241155} ) ;
156+
157+ describe ( 'ToolbarContent rowWrap' , ( ) => {
158+ const bps = [ 'default' , 'sm' , 'md' , 'lg' , 'xl' , '2xl' ] ;
159+
160+ bps . forEach ( ( bp ) => {
161+ it ( `should render with wrap at ${ bp } ` , ( ) => {
162+ render (
163+ < Toolbar >
164+ < ToolbarContent data-testid = "toolbarcontent" rowWrap = { { [ bp ] : 'wrap' } } >
165+ Test
166+ </ ToolbarContent >
167+ </ Toolbar >
168+ ) ;
169+ const cls = bp === 'default' ? 'pf-m-wrap' : `pf-m-wrap-on-${ bp } ` ;
170+ expect ( screen . getByTestId ( 'toolbarcontent' ) . querySelector ( 'div' ) ) . toHaveClass ( cls ) ;
171+ } ) ;
172+
173+ it ( `should render with nowrap at ${ bp } ` , ( ) => {
174+ render (
175+ < Toolbar >
176+ < ToolbarContent data-testid = "toolbarcontent" rowWrap = { { [ bp ] : 'nowrap' } } >
177+ Test
178+ </ ToolbarContent >
179+ </ Toolbar >
180+ ) ;
181+ const cls = bp === 'default' ? 'pf-m-nowrap' : `pf-m-nowrap-on-${ bp } ` ;
182+ expect ( screen . getByTestId ( 'toolbarcontent' ) . querySelector ( 'div' ) ) . toHaveClass ( cls ) ;
183+ } ) ;
184+ } ) ;
185+ } ) ;
0 commit comments