Skip to content

Commit

Permalink
Add tests for button loadingText.
Browse files Browse the repository at this point in the history
  • Loading branch information
avinashbot committed Oct 18, 2024
1 parent c7f361a commit 264abac
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/button/__tests__/button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { act, fireEvent, render } from '@testing-library/react';
import Button, { ButtonProps } from '../../../lib/components/button';
import InternalButton from '../../../lib/components/button/internal';
import createWrapper, { ButtonWrapper } from '../../../lib/components/test-utils/dom';
import LiveRegionWrapper from '../../../lib/components/test-utils/selectors/internal/live-region';
import { buttonRelExpectations, buttonTargetExpectations } from '../../__tests__/target-rel-test-helper';
import { renderWithSingleTabStopNavigation } from '../../internal/context/__tests__/utils';

Expand Down Expand Up @@ -60,6 +61,19 @@ describe('Button Component', () => {
expect(document.activeElement).toBe(wrapper.findButton()!.getElement());
});

describe('loadingText property', () => {
test('renders loadingText in a LiveRegion', () => {
renderButton({ children: 'Button', loading: true, loadingText: 'Loading' });
expect(createWrapper().findByClassName(LiveRegionWrapper.rootSelector)!.getElement()).toHaveTextContent(
'Loading'
);
});
test('does not render loadingText if loading is false', () => {
renderButton({ children: 'Button', loading: false, loadingText: 'Loading' });
expect(createWrapper().findByClassName(LiveRegionWrapper.rootSelector)).toBeNull();
});
});

describe('disabled property', () => {
test('renders button with normal styling by default', () => {
const wrapper = renderButton();
Expand Down

0 comments on commit 264abac

Please sign in to comment.