Skip to content

Commit 7eea998

Browse files
bhavikcodesYour Name
andauthored
test: improve coverage for Tasks component (#395)
* test: improve coverage for Tasks component * Refactor Tasks.test.tsx by cleaning up comments and empty rows Removed unnecessary comments and adjusted mock for TaskSkeleton component in tests. * ran npx prettier --check * test: add additional rendering coverage for Tasks * test: add additional basic coverage for Tasks component --------- Co-authored-by: Your Name <you@example.com>
1 parent 0f6b972 commit 7eea998

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

frontend/src/components/HomeComponents/Tasks/__tests__/Tasks.test.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ jest.mock('../Pagination', () => {
173173
));
174174
});
175175

176+
jest.mock('../TaskSkeleton', () => {
177+
return {
178+
__esModule: true,
179+
Taskskeleton: () => <div data-testid="task-skeleton" />,
180+
};
181+
});
182+
176183
global.fetch = jest.fn().mockResolvedValue({ ok: true });
177184

178185
describe('Tasks Component', () => {
@@ -217,6 +224,33 @@ describe('Tasks Component', () => {
217224
expect(dropdown).toBeInTheDocument();
218225
expect(dropdown).toHaveValue('10');
219226
});
227+
228+
test('does not render tasks when loading is true', () => {
229+
render(<Tasks {...mockProps} isLoading={true} />);
230+
expect(screen.queryByRole('row')).not.toBeInTheDocument();
231+
});
232+
233+
test('renders tasks container when loading is false', () => {
234+
render(<Tasks {...mockProps} isLoading={false} />);
235+
expect(screen.getByTestId('tasks')).toBeInTheDocument();
236+
});
237+
238+
test('renders BottomBar component', () => {
239+
render(<Tasks {...mockProps} />);
240+
expect(screen.getByText('Mocked BottomBar')).toBeInTheDocument();
241+
});
242+
243+
test('renders tasks section with correct id', () => {
244+
render(<Tasks {...mockProps} />);
245+
const section = document.querySelector('section#tasks');
246+
expect(section).toBeInTheDocument();
247+
});
248+
249+
test('renders Tasks component without crashing', () => {
250+
expect(() => {
251+
render(<Tasks {...mockProps} />);
252+
}).not.toThrow();
253+
});
220254
});
221255

222256
describe('LocalStorage', () => {

0 commit comments

Comments
 (0)