@@ -13,9 +13,12 @@ describe("Spinner component tests", () => {
1313 } ) ;
1414
1515 test ( "Small spinner hides value and label correctly" , ( ) => {
16- const { queryByText } = render ( < DxcSpinner mode = "small" label = "test-loading" value = { 75 } showValue > </ DxcSpinner > ) ;
16+ const { queryByText, getByRole } = render (
17+ < DxcSpinner mode = "small" label = "test-loading" value = { 75 } showValue > </ DxcSpinner >
18+ ) ;
1719 expect ( queryByText ( "test-loading" ) ) . toBeFalsy ( ) ;
1820 expect ( queryByText ( "75%" ) ) . toBeFalsy ( ) ;
21+ expect ( getByRole ( "progressbar" ) . getAttribute ( "aria-label" ) ) . toBe ( "Spinner" ) ;
1922 } ) ;
2023
2124 test ( "Overlay spinner shows value and label correctly" , ( ) => {
@@ -28,4 +31,20 @@ describe("Spinner component tests", () => {
2831 const { getByRole } = render ( < DxcSpinner label = "test-loading" value = { 75 } showValue > </ DxcSpinner > ) ;
2932 expect ( getByRole ( "progressbar" ) ) . toBeTruthy ( ) ;
3033 } ) ;
34+
35+ test ( "Test spinner aria-label to be undefined" , ( ) => {
36+ const { getByRole } = render ( < DxcSpinner label = "test-loading" value = { 75 } showValue > </ DxcSpinner > ) ;
37+ const spinner = getByRole ( "progressbar" ) ;
38+ expect ( spinner . getAttribute ( "aria-label" ) ) . toBeNull ( ) ;
39+ expect ( spinner . getAttribute ( "aria-labelledby" ) ) . toBeTruthy ( ) ;
40+ } ) ;
41+
42+ test ( "Test spinner aria-label to be applied correctly when mode is small" , ( ) => {
43+ const { getByRole } = render (
44+ < DxcSpinner label = "test-loading" ariaLabel = "Example aria label" value = { 75 } mode = "small" showValue > </ DxcSpinner >
45+ ) ;
46+ const spinner = getByRole ( "progressbar" ) ;
47+ expect ( spinner . getAttribute ( "aria-label" ) ) . toBe ( "Example aria label" ) ;
48+ expect ( spinner . getAttribute ( "aria-labelledby" ) ) . toBeNull ( ) ;
49+ } ) ;
3150} ) ;
0 commit comments