@@ -306,7 +306,8 @@ describe('Hamburger button', () => {
306306 ) ;
307307 } ) ;
308308
309- test ( 'Throws console error when isHamburger is true and neither aria-label nor aria-lablledby are passed' , ( ) => {
309+ // TODO: Remove isHamburger in breaking change to throw error for any button that does not have children or aria name
310+ test ( 'Throws console error when isHamburger is true and neither children, aria-label nor aria-lablledby are passed' , ( ) => {
310311 const consoleError = jest . spyOn ( console , 'error' ) . mockImplementation ( ) ;
311312
312313 render ( < Button isHamburger isExpanded /> ) ;
@@ -315,7 +316,22 @@ describe('Hamburger button', () => {
315316 'Button: you must provide either visible text content or an accessible name via the aria-label or aria-labelledby properties.'
316317 ) ;
317318 } ) ;
319+ // TODO: Remove isHamburger in breaking change to throw error for any button that does not have children or aria name
320+ test ( 'Does not throw console error when isHamburger is true and children is passed' , ( ) => {
321+ const consoleError = jest . spyOn ( console , 'error' ) . mockImplementation ( ) ;
322+
323+ render (
324+ < Button isHamburger isExpanded >
325+ Test
326+ </ Button >
327+ ) ;
318328
329+ expect ( consoleError ) . not . toHaveBeenCalledWith (
330+ 'Button: you must provide either visible text content or an accessible name via the aria-label or aria-labelledby properties.'
331+ ) ;
332+ } ) ;
333+
334+ // TODO: Remove isHamburger in breaking change to throw error for any button that does not have children or aria name
319335 test ( 'Does not throw console error when isHamburger is true and aria-label is passed' , ( ) => {
320336 const consoleError = jest . spyOn ( console , 'error' ) . mockImplementation ( ) ;
321337
@@ -326,6 +342,7 @@ describe('Hamburger button', () => {
326342 ) ;
327343 } ) ;
328344
345+ // TODO: Remove isHamburger in breaking change to throw error for any button that does not have children or aria name
329346 test ( 'Does not throw console error when isHamburger is true and aria-labelledby is passed' , ( ) => {
330347 const consoleError = jest . spyOn ( console , 'error' ) . mockImplementation ( ) ;
331348
@@ -341,19 +358,32 @@ describe('Hamburger button', () => {
341358 ) ;
342359 } ) ;
343360
361+ test ( `Does not render with class ${ styles . modifiers . hamburger } by default` , ( ) => {
362+ render ( < Button aria-label = "test" /> ) ;
363+
364+ expect ( screen . getByRole ( 'button' ) ) . not . toHaveClass ( styles . modifiers . hamburger ) ;
365+ } ) ;
366+
344367 test ( `Renders with class ${ styles . modifiers . hamburger } when isHamburger is true` , ( ) => {
345368 render ( < Button isHamburger isExpanded aria-label = "test" /> ) ;
346369
347370 expect ( screen . getByRole ( 'button' ) ) . toHaveClass ( styles . modifiers . hamburger ) ;
348371 } ) ;
349372
350- test ( 'Does not render with hamburgerVariant class when isHamburger is false ' , ( ) => {
373+ test ( 'Does not render with hamburgerVariant class when isHamburger is true and hamburgerVariant is not passed ' , ( ) => {
351374 render ( < Button isHamburger isExpanded aria-label = "test" /> ) ;
352375
353376 expect ( screen . getByRole ( 'button' ) ) . not . toHaveClass ( styles . modifiers . expand ) ;
354377 expect ( screen . getByRole ( 'button' ) ) . not . toHaveClass ( styles . modifiers . collapse ) ;
355378 } ) ;
356379
380+ test ( 'Does not render with hamburgerVariant class when isHamburger is false and hamburgerVariant is passed' , ( ) => {
381+ render ( < Button hamburgerVariant = "expand" isExpanded aria-label = "test" /> ) ;
382+
383+ expect ( screen . getByRole ( 'button' ) ) . not . toHaveClass ( styles . modifiers . expand ) ;
384+ expect ( screen . getByRole ( 'button' ) ) . not . toHaveClass ( styles . modifiers . collapse ) ;
385+ } ) ;
386+
357387 test ( `Renders with class ${ styles . modifiers . expand } when isHamburger is true and hamburgerVariant = expand` , ( ) => {
358388 render ( < Button isHamburger hamburgerVariant = "expand" isExpanded aria-label = "test" /> ) ;
359389
@@ -368,32 +398,15 @@ describe('Hamburger button', () => {
368398 expect ( screen . getByRole ( 'button' ) ) . toHaveClass ( styles . modifiers . collapse ) ;
369399 } ) ;
370400
371- test ( 'Forces plain variant when isHamburger is passed' , ( ) => {
372- render ( < Button variant = "secondary" isHamburger isExpanded aria-label = "test" /> ) ;
373-
374- expect ( screen . getByRole ( 'button' ) ) . not . toHaveClass ( styles . modifiers . secondary ) ;
375- expect ( screen . getByRole ( 'button' ) ) . toHaveClass ( styles . modifiers . plain ) ;
376- } ) ;
377-
378401 test ( 'Does not render custom icon when icon prop and isHamburger are passed' , ( ) => {
379402 render ( < Button isHamburger isExpanded aria-label = "test" icon = { < div > Custom icon</ div > } /> ) ;
380403
381404 expect ( screen . queryByText ( 'Custom icon' ) ) . not . toBeInTheDocument ( ) ;
382405 } ) ;
383-
384- test ( 'Does not render text content when isHamburger is passed' , ( ) => {
385- render (
386- < Button isHamburger isExpanded aria-label = "test" >
387- Hamburger text content
388- </ Button >
389- ) ;
390-
391- expect ( screen . queryByText ( 'Hamburger text content' ) ) . not . toBeInTheDocument ( ) ;
392- } ) ;
393406} ) ;
394407
395408describe ( 'Settings button' , ( ) => {
396- // TODO: Remove isSettings in breaking change to throw error for any non-hamburger button that does not have children or aria-label
409+ // TODO: Remove isSettings in breaking change to throw error for any button that does not have children or aria name
397410 test ( 'Throws console error when isSettings is true and neither children, aria-label nor aria-lablledby are passed' , ( ) => {
398411 const consoleError = jest . spyOn ( console , 'error' ) . mockImplementation ( ) ;
399412
@@ -404,7 +417,7 @@ describe('Settings button', () => {
404417 ) ;
405418 } ) ;
406419
407- // TODO: Remove isSettings in breaking change to throw error for any non-hamburger button that does not have children or aria-label
420+ // TODO: Remove isSettings in breaking change to throw error for any button that does not have children or aria name
408421 test ( 'Does not throw console error when isSettings is true and children is passed' , ( ) => {
409422 const consoleError = jest . spyOn ( console , 'error' ) . mockImplementation ( ) ;
410423
@@ -415,7 +428,7 @@ describe('Settings button', () => {
415428 ) ;
416429 } ) ;
417430
418- // TODO: Remove isSettings in breaking change to throw error for any non-hamburger button that does not have children or aria-label
431+ // TODO: Remove isSettings in breaking change to throw error for any button that does not have children or aria name
419432 test ( 'Does not throw console error when isSettings is true and aria-label is passed' , ( ) => {
420433 const consoleError = jest . spyOn ( console , 'error' ) . mockImplementation ( ) ;
421434
@@ -426,7 +439,7 @@ describe('Settings button', () => {
426439 ) ;
427440 } ) ;
428441
429- // TODO: Remove isSettings in breaking change to throw error for any non-hamburger button that does not have children or aria-label
442+ // TODO: Remove isSettings in breaking change to throw error for any button that does not have children or aria name
430443 test ( 'Does not throw console error when isSettings is true and aria-labelledby is passed' , ( ) => {
431444 const consoleError = jest . spyOn ( console , 'error' ) . mockImplementation ( ) ;
432445
@@ -442,17 +455,16 @@ describe('Settings button', () => {
442455 ) ;
443456 } ) ;
444457
445- test ( `Renders with class ${ styles . modifiers . settings } when isSettings is true ` , ( ) => {
446- render ( < Button isSettings aria-label = "test" /> ) ;
458+ test ( `Does not render with class ${ styles . modifiers . settings } by default ` , ( ) => {
459+ render ( < Button aria-label = "test" /> ) ;
447460
448- expect ( screen . getByRole ( 'button' ) ) . toHaveClass ( styles . modifiers . settings ) ;
461+ expect ( screen . getByRole ( 'button' ) ) . not . toHaveClass ( styles . modifiers . settings ) ;
449462 } ) ;
450463
451- test ( 'Forces plain variant when isSettings is passed' , ( ) => {
452- render ( < Button variant = "secondary" isSettings aria-label = "test" /> ) ;
464+ test ( `Renders with class ${ styles . modifiers . settings } when isSettings is true` , ( ) => {
465+ render ( < Button isSettings aria-label = "test" /> ) ;
453466
454- expect ( screen . getByRole ( 'button' ) ) . not . toHaveClass ( styles . modifiers . secondary ) ;
455- expect ( screen . getByRole ( 'button' ) ) . toHaveClass ( styles . modifiers . plain ) ;
467+ expect ( screen . getByRole ( 'button' ) ) . toHaveClass ( styles . modifiers . settings ) ;
456468 } ) ;
457469
458470 test ( 'Does not render custom icon when icon prop and isSettings are passed' , ( ) => {
0 commit comments