@@ -3,6 +3,7 @@ import { render, screen } from "@testing-library/react";
33
44import "@testing-library/jest-dom" ;
55
6+ import { CLASSPREFIX as eccgui } from "../../configuration/constants" ;
67import Icon from "../Icon/Icon" ;
78
89import Button from "./Button" ;
@@ -21,7 +22,7 @@ describe("Button", () => {
2122 </ Button >
2223 ) ;
2324 expect ( screen . getByRole ( "button" ) . lastChild ) . toEqual ( screen . getByText ( / l e f t i c o n / i) ) ;
24- expect ( container . getElementsByClassName ( " eccgui-icon" ) . length ) . toBe ( 1 ) ;
25+ expect ( container . getElementsByClassName ( ` ${ eccgui } -icon` ) . length ) . toBe ( 1 ) ;
2526 } ) ;
2627
2728 it ( "should have icon at the right after the text" , ( ) => {
@@ -31,6 +32,19 @@ describe("Button", () => {
3132 </ Button >
3233 ) ;
3334 expect ( screen . getByRole ( "button" ) . firstChild ) . toEqual ( screen . getByText ( / r i g h t i c o n / i) ) ;
34- expect ( container . getElementsByClassName ( "eccgui-icon" ) . length ) . toBe ( 1 ) ;
35+ expect ( container . getElementsByClassName ( `${ eccgui } -icon` ) . length ) . toBe ( 1 ) ;
36+ } ) ;
37+
38+ it ( "should render badge markup with correct content when used on an icon button" , ( ) => {
39+ const { container } = render ( < Button name = "item-info" badge = { "badge content" } text = { "Cation label" } /> ) ;
40+ const badge = container . querySelector ( `.${ eccgui } -badge` ) ;
41+ expect ( badge ) . not . toBeNull ( ) ;
42+ expect ( badge ) . toHaveTextContent ( "badge content" ) ;
43+ } ) ;
44+ it ( "should render badge markup with correct content when batch displays a 0 (zero) number on an icon button" , ( ) => {
45+ const { container } = render ( < Button name = "item-info" badge = { 0 } text = { "Cation label" } /> ) ;
46+ const badge = container . querySelector ( `.${ eccgui } -badge` ) ;
47+ expect ( badge ) . not . toBeNull ( ) ;
48+ expect ( badge ) . toHaveTextContent ( "0" ) ;
3549 } ) ;
3650} ) ;
0 commit comments