Skip to content

Commit

Permalink
fixed linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
syedali237 committed Jan 16, 2025
1 parent d889240 commit d766b80
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 25 deletions.
40 changes: 39 additions & 1 deletion src/screens/Users/Users.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
MOCKS_NEW2,
MOCKS_NEW3,
MOCKS_NEW_2,
} from './UsersMocks';
} from './UsersMocks.mocks';
import useLocalStorage from 'utils/useLocalstorage';
import { describe, expect, it, beforeEach, afterEach, vi } from 'vitest';

Expand Down Expand Up @@ -841,4 +841,42 @@ describe('Testing Users screen', () => {
expect(rows.length).toBe(4);
});
});

it('renders InfiniteScroll with empty users list', async () => {
render(
<MockedProvider mocks={EMPTY_MOCKS} addTypename={false}>
<BrowserRouter>
<Provider store={store}>
<I18nextProvider i18n={i18nForTest}>
<Users />
</I18nextProvider>
</Provider>
</BrowserRouter>
</MockedProvider>,
);

await wait();
const infiniteScroll = screen.getByTestId('users-list');
expect(infiniteScroll).toBeInTheDocument();
expect(infiniteScroll).toHaveAttribute('data-length', '0');
});

it('renders InfiniteScroll with users list', async () => {
render(
<MockedProvider mocks={MOCKS_NEW} addTypename={false}>
<BrowserRouter>
<Provider store={store}>
<I18nextProvider i18n={i18nForTest}>
<Users />
</I18nextProvider>
</Provider>
</BrowserRouter>
</MockedProvider>,
);

await wait();
const infiniteScroll = screen.getByTestId('users-list');
expect(infiniteScroll).toBeInTheDocument();
expect(infiniteScroll).toHaveAttribute('data-length', '12'); // Assuming `MOCKS_NEW` returns 12 users
});
});
5 changes: 1 addition & 4 deletions src/screens/Users/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,7 @@ const Users = (): JSX.Element => {
/>
)}
<InfiniteScroll
dataLength={
/* istanbul ignore next */
displayedUsers.length ?? 0
}
dataLength={displayedUsers.length ?? 0}
next={() => {
loadMoreUsers(displayedUsers.length, perPageResult);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,26 +503,6 @@ export const EMPTY_MOCKS = [
},
];

export const EMPTY_MOCK_NEW = [
{
request: {
query: USER_LIST,
variables: {
first: 12,
skip: 0,
firstName_contains: 'NonexistentName',
lastName_contains: '',
order: 'createdAt_DESC',
},
},
result: {
data: {
users: [],
},
},
},
];

export const createAddress = {
city: 'Kingston',
countryCode: 'JM',
Expand Down

0 comments on commit d766b80

Please sign in to comment.