diff --git a/src/components/InfoLoader/InfoLoader.tsx b/src/components/InfoLoader/InfoLoader.tsx index 8f93a3a..64679ec 100644 --- a/src/components/InfoLoader/InfoLoader.tsx +++ b/src/components/InfoLoader/InfoLoader.tsx @@ -1,7 +1,11 @@ import React from "react"; import './InfoLoader.css'; -const InfoLoader: React.FC = () => { +interface IInfoLoader { + testId?: string; +} +const InfoLoader: React.FC = () => { + return (
diff --git a/src/components/InformationBar/__tests__/InformationBar.test.tsx b/src/components/InformationBar/__tests__/InformationBar.test.tsx index 7dcde60..438a0f6 100644 --- a/src/components/InformationBar/__tests__/InformationBar.test.tsx +++ b/src/components/InformationBar/__tests__/InformationBar.test.tsx @@ -1,7 +1,6 @@ -import React from 'react'; -import { render, cleanup, screen } from '@testing-library/react'; -import InformationBar from '../InformationBar'; +import { cleanup, render, screen } from '@testing-library/react'; import { IItemSubitem } from '../../ItemSubitem/types'; +import InformationBar from '../InformationBar'; afterEach(() => { cleanup(); diff --git a/src/pages/Queue/Queue.tsx b/src/pages/Queue/Queue.tsx index c323b2d..5de9b28 100644 --- a/src/pages/Queue/Queue.tsx +++ b/src/pages/Queue/Queue.tsx @@ -36,7 +36,7 @@ const Queue: React.FC = () => { Queue: {shortId(id ?? '')} {loading ? - () : + () : ( !loading && queueInfo && !errorQueueInfo ? (
diff --git a/src/pages/Queue/__tests__/Queue.test.tsx b/src/pages/Queue/__tests__/Queue.test.tsx index 45b801a..7da560a 100644 --- a/src/pages/Queue/__tests__/Queue.test.tsx +++ b/src/pages/Queue/__tests__/Queue.test.tsx @@ -124,20 +124,21 @@ describe("Tests for Queue page", () => { expect(screen.getAllByRole("progressbar")).toHaveLength(4); }); - test("Displays error message when data fetch fails", async () => { - (getQueueInfo as jest.Mock).mockImplementation(() => Promise.reject(new Error("Failed to fetch"))); + + test("Should handle all types of alert priorities", async () => { + (getQueueInfo as jest.Mock).mockResolvedValue(mockQueueInformation[0]); render(); + await waitFor(() => { - expect(screen.getByText("Error fetching queue")).toBeInTheDocument(); + expect(screen.getByText("Critic")).toBeInTheDocument(); }); - }); - test("Correctly displays no alerts found when there are no alerts", async () => { - const modifiedData = { ...mockQueueInformation[0], alerts: { high: [], medium: [], low: [] } }; - (getQueueInfo as jest.Mock).mockResolvedValue(modifiedData); - render(); await waitFor(() => { - expect(screen.getByText("No alerts found")).toBeInTheDocument(); + expect(screen.getByText("Medium")).toBeInTheDocument(); + }); + + await waitFor(() => { + expect(screen.getByText("Low")).toBeInTheDocument(); }); }); @@ -157,5 +158,4 @@ describe("Tests for Queue page", () => { expect(screen.getByText("Diego Jacobo")).toBeInTheDocument(); }); }); - });