From e8ff8e9011bb018dab6300549046cd7430eeef5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Sun, 8 Oct 2023 20:16:37 +0200 Subject: [PATCH] Update test --- .github/workflows/ci.yml | 3 ++ .../components/software/SoftwarePage.test.jsx | 28 +++++++++---------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d941c5d41d..4e70e58994 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,9 @@ jobs: - name: Run Stylelint run: npm run stylelint + - name: Run the tests + run: npm test -- SoftwarePage + - name: Run the tests and generate coverage report run: npm test -- --coverage diff --git a/web/src/components/software/SoftwarePage.test.jsx b/web/src/components/software/SoftwarePage.test.jsx index 446bf18521..2f49e4cab7 100644 --- a/web/src/components/software/SoftwarePage.test.jsx +++ b/web/src/components/software/SoftwarePage.test.jsx @@ -20,16 +20,26 @@ */ import React from "react"; + import { act, screen } from "@testing-library/react"; -import { installerRender, mockComponent } from "~/test-utils"; +import { installerRender } from "~/test-utils"; import { BUSY, IDLE } from "~/client/status"; - import { createClient } from "~/client"; import SoftwarePage from "./SoftwarePage"; -const PatternSelectorMock = " Mock"; -jest.mock("~/components/software/PatternSelector", () => mockComponent(PatternSelectorMock)); +const SkeletonMock = "Skeleton mock"; +jest.mock("@patternfly/react-core", () => { + const original = jest.requireActual("@patternfly/react-core"); + + return { + ...original, + Skeleton: () => { return {SkeletonMock} } + }; +}); + +const PatternSelectorMock = "PatternSelector mock"; +jest.mock("~/components/software/PatternSelector", () => () => { return PatternSelectorMock }); jest.mock("~/client"); const getStatusFn = jest.fn(); const onStatusChangeFn = jest.fn(); @@ -44,16 +54,6 @@ beforeEach(() => { }); }); -const SkeletonMock = " mock"; -jest.mock("@patternfly/react-core", () => { - const original = jest.requireActual("@patternfly/react-core"); - - return { - ...original, - Skeleton: mockComponent(SkeletonMock) - }; -}); - describe("SoftwarePage", () => { it("displays a progress when the backend in busy", async () => { getStatusFn.mockResolvedValue(BUSY);