Skip to content

Commit

Permalink
feat: add default qa attribute to the Loader element
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisVershkov committed Apr 15, 2024
1 parent e36ec12 commit 12421f2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/components/List/__tests__/List.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ describe('base List', () => {
it('should render loading indicator', () => {
setup({virtualized: false, onLoadMore: mockOnLoadMorFn, loading: true});

const loader = screen.getByRole('list').querySelector('.g-loader');
const loader = screen.getByTestId('loader');
expect(loader).toBeInTheDocument();
});
it('should call onLoadMore callback when loading indicator is visible', () => {
setup({virtualized: false, onLoadMore: mockOnLoadMorFn, loading: true});

const loader = screen.getByRole('list').querySelector('.g-loader');
const loader = screen.getByTestId('loader');

expect(loader).toBeVisible();
expect(mockOnLoadMorFn).toHaveBeenCalled();
Expand All @@ -54,14 +54,14 @@ describe('virtualized List', () => {
it('should render loading indicator', () => {
setup({virtualized: true, onLoadMore: mockOnLoadMorFn, loading: true});

const loader = screen.getByRole('list').querySelector('.g-loader');
const loader = screen.getByTestId('loader');
expect(loader).toBeInTheDocument();
});

it('should call onLoadMore callback when loading indicator is visible', () => {
setup({virtualized: true, onLoadMore: mockOnLoadMorFn, loading: true});

const loader = screen.getByRole('list').querySelector('.g-loader');
const loader = screen.getByTestId('loader');
expect(loader).toBeVisible();
expect(mockOnLoadMorFn).toHaveBeenCalled();
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/Loader/Loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface LoaderProps extends QAProps {
size?: LoaderSize;
}

export function Loader({size = 's', className, qa}: LoaderProps) {
export function Loader({size = 's', className, qa = 'loader'}: LoaderProps) {
return (
<div className={b({size}, className)} data-qa={qa}>
<div className={b('left')} />
Expand Down

0 comments on commit 12421f2

Please sign in to comment.