From cbbc3496bb8b59ee17a9d2956720366d84889fce Mon Sep 17 00:00:00 2001 From: kenchan0130 Date: Sat, 7 Oct 2023 01:31:17 +0900 Subject: [PATCH] fix test --- test/index.test.ts | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/test/index.test.ts b/test/index.test.ts index dd2a92b..14f26ff 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -1,18 +1,17 @@ +import * as core from "@actions/core"; import { beforeEach, describe, expect, it, vi } from "vitest"; -const mockSetOutput = vi.fn(); - import { main } from "../src"; import { nonEmptyStringExpect } from "./helpers/helper"; vi.mock("@actions/core", () => { return { - setOutput: mockSetOutput, - debug: (message: string) => { - console.log(message); + setOutput: vi.fn(), + debug: (_: string) => { + return; }, - setFailed: (message: string) => { - console.error(message); + setFailed: (_: string) => { + return; }, }; }); @@ -25,19 +24,19 @@ describe("main", () => { it("should set correct outputs", async () => { await main(); - expect(mockSetOutput).toBeCalledWith("cpu-core", expect.any(Number)); - expect(mockSetOutput).toBeCalledWith("cpu-model", nonEmptyStringExpect); - expect(mockSetOutput).toBeCalledWith("hostname", nonEmptyStringExpect); - expect(mockSetOutput).toBeCalledWith( + expect(core.setOutput).toBeCalledWith("cpu-core", expect.any(Number)); + expect(core.setOutput).toBeCalledWith("cpu-model", nonEmptyStringExpect); + expect(core.setOutput).toBeCalledWith("hostname", nonEmptyStringExpect); + expect(core.setOutput).toBeCalledWith( "kernel-release", nonEmptyStringExpect ); - expect(mockSetOutput).toBeCalledWith( + expect(core.setOutput).toBeCalledWith( "kernel-version", nonEmptyStringExpect ); - expect(mockSetOutput).toBeCalledWith("name", nonEmptyStringExpect); - expect(mockSetOutput).toBeCalledWith("release", nonEmptyStringExpect); - expect(mockSetOutput).toBeCalledWith("totalmem", expect.any(Number)); + expect(core.setOutput).toBeCalledWith("name", nonEmptyStringExpect); + expect(core.setOutput).toBeCalledWith("release", nonEmptyStringExpect); + expect(core.setOutput).toBeCalledWith("totalmem", expect.any(Number)); }); });