From 12421f2a9d8b0a0286527c40465f999152a0fe45 Mon Sep 17 00:00:00 2001 From: Denis Vershkov Date: Mon, 15 Apr 2024 16:30:22 +0300 Subject: [PATCH] feat: add default qa attribute to the Loader element --- src/components/List/__tests__/List.test.tsx | 8 ++++---- src/components/Loader/Loader.tsx | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/List/__tests__/List.test.tsx b/src/components/List/__tests__/List.test.tsx index 3eeed79cfc..4a2ef3fb11 100644 --- a/src/components/List/__tests__/List.test.tsx +++ b/src/components/List/__tests__/List.test.tsx @@ -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(); @@ -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(); }); diff --git a/src/components/Loader/Loader.tsx b/src/components/Loader/Loader.tsx index 7b97cb723e..e5a094c5c0 100644 --- a/src/components/Loader/Loader.tsx +++ b/src/components/Loader/Loader.tsx @@ -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 (