From 8d491eb0d8db3f156095279cc88db0d6909c41f3 Mon Sep 17 00:00:00 2001 From: Denis Vershkov Date: Tue, 16 Apr 2024 22:08:14 +0300 Subject: [PATCH] chore: update naming; move qa attribute --- src/components/List/List.tsx | 6 ++---- src/components/List/ListLoadingIndicator.tsx | 4 ++-- src/components/List/__tests__/List.test.tsx | 8 ++++---- src/components/Loader/Loader.tsx | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/components/List/List.tsx b/src/components/List/List.tsx index a238cafadb..b69f8a7539 100644 --- a/src/components/List/List.tsx +++ b/src/components/List/List.tsx @@ -15,13 +15,13 @@ import AutoSizer from 'react-virtualized-auto-sizer'; import type {VariableSizeListProps} from 'react-window'; import {VariableSizeList} from 'react-window'; -import {SelectLoadingIndicator} from '../Select/components/SelectList/SelectLoadingIndicator'; import {TextInput} from '../controls'; import {MobileContext} from '../mobile'; import {useDirection} from '../theme'; import {block} from '../utils/cn'; import {getUniqId} from '../utils/common'; +import {ListLoadingIndicator} from './ListLoadingIndicator'; import {ListItem, SimpleContainer, defaultRenderItem} from './components'; import {listNavigationIgnoredKeys} from './constants'; import type {ListItemData, ListItemProps, ListProps} from './types'; @@ -260,9 +260,7 @@ export class List extends React.Component, ListState - ); + return ; } return this.props.renderItem diff --git a/src/components/List/ListLoadingIndicator.tsx b/src/components/List/ListLoadingIndicator.tsx index 4bbb9e79cd..885a002af8 100644 --- a/src/components/List/ListLoadingIndicator.tsx +++ b/src/components/List/ListLoadingIndicator.tsx @@ -5,14 +5,14 @@ import {Loader} from '../Loader'; import {block} from '../utils/cn'; const b = block('list'); -export const SelectLoadingIndicator = (props: {onIntersect?: () => void}) => { +export const ListLoadingIndicator = (props: {onIntersect?: () => void}) => { const ref = React.useRef(null); useIntersection({element: ref.current, onIntersect: props?.onIntersect}); return (
- +
); }; diff --git a/src/components/List/__tests__/List.test.tsx b/src/components/List/__tests__/List.test.tsx index 4a2ef3fb11..5a1849a931 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.getByTestId('loader'); + const loader = screen.getByTestId('list-loader'); expect(loader).toBeInTheDocument(); }); it('should call onLoadMore callback when loading indicator is visible', () => { setup({virtualized: false, onLoadMore: mockOnLoadMorFn, loading: true}); - const loader = screen.getByTestId('loader'); + const loader = screen.getByTestId('list-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.getByTestId('loader'); + const loader = screen.getByTestId('list-loader'); expect(loader).toBeInTheDocument(); }); it('should call onLoadMore callback when loading indicator is visible', () => { setup({virtualized: true, onLoadMore: mockOnLoadMorFn, loading: true}); - const loader = screen.getByTestId('loader'); + const loader = screen.getByTestId('list-loader'); expect(loader).toBeVisible(); expect(mockOnLoadMorFn).toHaveBeenCalled(); }); diff --git a/src/components/Loader/Loader.tsx b/src/components/Loader/Loader.tsx index e5a094c5c0..7b97cb723e 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 = 'loader'}: LoaderProps) { +export function Loader({size = 's', className, qa}: LoaderProps) { return (