Loading __tests__/actionUtils.test.ts +7 −8 Changes for __tests__/actionUtils.test.ts: 7 added lines, 8 removed lines. Original line number Diff line number Diff line import { jest, test, expect, beforeEach, afterAll } from "@jest/globals"; import { afterAll, beforeEach, expect, jest, test } from "@jest/globals"; // Mock @actions/core jest.unstable_mockModule("@actions/core", () => ({ Loading Loading @@ -53,13 +53,10 @@ beforeEach(() => { (core.getInput as jest.Mock).mockImplementation( (name: string, options?: { required?: boolean }) => { const val = process.env[ `INPUT_${name.replace(/ /g, "_").toUpperCase()}` ] || ""; process.env[`INPUT_${name.replace(/ /g, "_").toUpperCase()}`] || ""; if (options && options.required && !val) { throw new Error( `Input required and not supplied: ${name}` ); throw new Error(`Input required and not supplied: ${name}`); } return val.trim(); } Loading Loading @@ -103,7 +100,9 @@ test("isExactKeyMatch with different keys returns false", () => { }); test("isExactKeyMatch with different key accents returns false", () => { expect(actionUtils.isExactKeyMatch("linux-áccent", "linux-accent")).toBe(false); expect(actionUtils.isExactKeyMatch("linux-áccent", "linux-accent")).toBe( false ); }); test("isExactKeyMatch with same key returns true", () => { Loading __tests__/restore.test.ts +4 −7 Changes for __tests__/restore.test.ts: 4 added lines, 7 removed lines. Original line number Diff line number Diff line import { jest, test, expect, beforeEach, afterEach } from "@jest/globals"; import { afterEach, beforeEach, expect, jest, test } from "@jest/globals"; // Mock @actions/core jest.unstable_mockModule("@actions/core", () => ({ Loading Loading @@ -50,13 +50,10 @@ beforeEach(() => { (core.getInput as jest.Mock).mockImplementation( (name: string, options?: { required?: boolean }) => { const val = process.env[ `INPUT_${name.replace(/ /g, "_").toUpperCase()}` ] || ""; process.env[`INPUT_${name.replace(/ /g, "_").toUpperCase()}`] || ""; if (options && options.required && !val) { throw new Error( `Input required and not supplied: ${name}` ); throw new Error(`Input required and not supplied: ${name}`); } return val.trim(); } Loading __tests__/restoreImpl.test.ts +11 −9 Changes for __tests__/restoreImpl.test.ts: 11 added lines, 9 removed lines. Original line number Diff line number Diff line import { jest, test, expect, beforeEach, afterEach } from "@jest/globals"; import { afterEach, beforeEach, expect, jest, test } from "@jest/globals"; // Mock @actions/core jest.unstable_mockModule("@actions/core", () => ({ Loading Loading @@ -51,13 +51,10 @@ beforeEach(() => { (core.getInput as jest.Mock).mockImplementation( (name: string, options?: { required?: boolean }) => { const val = process.env[ `INPUT_${name.replace(/ /g, "_").toUpperCase()}` ] || ""; process.env[`INPUT_${name.replace(/ /g, "_").toUpperCase()}`] || ""; if (options && options.required && !val) { throw new Error( `Input required and not supplied: ${name}` ); throw new Error(`Input required and not supplied: ${name}`); } return val.trim(); } Loading Loading @@ -182,7 +179,9 @@ test("restore with large key should fail", async () => { enableCrossOsArchive: false }); (cache.restoreCache as jest.Mock).mockRejectedValue( new Error(`Key Validation Error: ${key} cannot be larger than 512 characters.`) new Error( `Key Validation Error: ${key} cannot be larger than 512 characters.` ) ); await restoreImpl(new StateProvider()); expect(cache.restoreCache).toHaveBeenCalledTimes(1); Loading Loading @@ -336,7 +335,10 @@ test("restore with lookup-only set", async () => { test("restore failure with earlyExit should call process exit", async () => { testUtils.setInput(Inputs.Path, "node_modules"); const processExitMock = jest.spyOn(process, "exit").mockImplementation((() => {}) as any); const processExitMock = jest .spyOn(process, "exit") // eslint-disable-next-line @typescript-eslint/no-explicit-any .mockImplementation((() => {}) as any); await restoreImpl(new StateProvider(), true); Loading __tests__/restoreOnly.test.ts +8 −8 Changes for __tests__/restoreOnly.test.ts: 8 added lines, 8 removed lines. Original line number Diff line number Diff line import { jest, test, expect, beforeEach, afterEach } from "@jest/globals"; import { afterEach, beforeEach, expect, jest, test } from "@jest/globals"; // Mock @actions/core jest.unstable_mockModule("@actions/core", () => ({ Loading Loading @@ -50,13 +50,10 @@ beforeEach(() => { (core.getInput as jest.Mock).mockImplementation( (name: string, options?: { required?: boolean }) => { const val = process.env[ `INPUT_${name.replace(/ /g, "_").toUpperCase()}` ] || ""; process.env[`INPUT_${name.replace(/ /g, "_").toUpperCase()}`] || ""; if (options && options.required && !val) { throw new Error( `Input required and not supplied: ${name}` ); throw new Error(`Input required and not supplied: ${name}`); } return val.trim(); } Loading Loading @@ -167,7 +164,10 @@ test("restore with cache found for restore key", async () => { expect(cache.restoreCache).toHaveBeenCalledTimes(1); expect(core.setOutput).toHaveBeenCalledWith("cache-primary-key", key); expect(core.setOutput).toHaveBeenCalledWith("cache-hit", "false"); expect(core.setOutput).toHaveBeenCalledWith("cache-matched-key", restoreKey); expect(core.setOutput).toHaveBeenCalledWith( "cache-matched-key", restoreKey ); expect(core.setOutput).toHaveBeenCalledTimes(3); expect(core.info).toHaveBeenCalledWith( `Cache restored from key: ${restoreKey}` Loading __tests__/save.test.ts +4 −7 Changes for __tests__/save.test.ts: 4 added lines, 7 removed lines. Original line number Diff line number Diff line import { jest, test, expect, beforeEach, afterEach } from "@jest/globals"; import { afterEach, beforeEach, expect, jest, test } from "@jest/globals"; // Mock @actions/core jest.unstable_mockModule("@actions/core", () => ({ Loading Loading @@ -50,13 +50,10 @@ beforeEach(() => { (core.getInput as jest.Mock).mockImplementation( (name: string, options?: { required?: boolean }) => { const val = process.env[ `INPUT_${name.replace(/ /g, "_").toUpperCase()}` ] || ""; process.env[`INPUT_${name.replace(/ /g, "_").toUpperCase()}`] || ""; if (options && options.required && !val) { throw new Error( `Input required and not supplied: ${name}` ); throw new Error(`Input required and not supplied: ${name}`); } return val.trim(); } Loading Loading
__tests__/actionUtils.test.ts +7 −8 Changes for __tests__/actionUtils.test.ts: 7 added lines, 8 removed lines. Original line number Diff line number Diff line import { jest, test, expect, beforeEach, afterAll } from "@jest/globals"; import { afterAll, beforeEach, expect, jest, test } from "@jest/globals"; // Mock @actions/core jest.unstable_mockModule("@actions/core", () => ({ Loading Loading @@ -53,13 +53,10 @@ beforeEach(() => { (core.getInput as jest.Mock).mockImplementation( (name: string, options?: { required?: boolean }) => { const val = process.env[ `INPUT_${name.replace(/ /g, "_").toUpperCase()}` ] || ""; process.env[`INPUT_${name.replace(/ /g, "_").toUpperCase()}`] || ""; if (options && options.required && !val) { throw new Error( `Input required and not supplied: ${name}` ); throw new Error(`Input required and not supplied: ${name}`); } return val.trim(); } Loading Loading @@ -103,7 +100,9 @@ test("isExactKeyMatch with different keys returns false", () => { }); test("isExactKeyMatch with different key accents returns false", () => { expect(actionUtils.isExactKeyMatch("linux-áccent", "linux-accent")).toBe(false); expect(actionUtils.isExactKeyMatch("linux-áccent", "linux-accent")).toBe( false ); }); test("isExactKeyMatch with same key returns true", () => { Loading
__tests__/restore.test.ts +4 −7 Changes for __tests__/restore.test.ts: 4 added lines, 7 removed lines. Original line number Diff line number Diff line import { jest, test, expect, beforeEach, afterEach } from "@jest/globals"; import { afterEach, beforeEach, expect, jest, test } from "@jest/globals"; // Mock @actions/core jest.unstable_mockModule("@actions/core", () => ({ Loading Loading @@ -50,13 +50,10 @@ beforeEach(() => { (core.getInput as jest.Mock).mockImplementation( (name: string, options?: { required?: boolean }) => { const val = process.env[ `INPUT_${name.replace(/ /g, "_").toUpperCase()}` ] || ""; process.env[`INPUT_${name.replace(/ /g, "_").toUpperCase()}`] || ""; if (options && options.required && !val) { throw new Error( `Input required and not supplied: ${name}` ); throw new Error(`Input required and not supplied: ${name}`); } return val.trim(); } Loading
__tests__/restoreImpl.test.ts +11 −9 Changes for __tests__/restoreImpl.test.ts: 11 added lines, 9 removed lines. Original line number Diff line number Diff line import { jest, test, expect, beforeEach, afterEach } from "@jest/globals"; import { afterEach, beforeEach, expect, jest, test } from "@jest/globals"; // Mock @actions/core jest.unstable_mockModule("@actions/core", () => ({ Loading Loading @@ -51,13 +51,10 @@ beforeEach(() => { (core.getInput as jest.Mock).mockImplementation( (name: string, options?: { required?: boolean }) => { const val = process.env[ `INPUT_${name.replace(/ /g, "_").toUpperCase()}` ] || ""; process.env[`INPUT_${name.replace(/ /g, "_").toUpperCase()}`] || ""; if (options && options.required && !val) { throw new Error( `Input required and not supplied: ${name}` ); throw new Error(`Input required and not supplied: ${name}`); } return val.trim(); } Loading Loading @@ -182,7 +179,9 @@ test("restore with large key should fail", async () => { enableCrossOsArchive: false }); (cache.restoreCache as jest.Mock).mockRejectedValue( new Error(`Key Validation Error: ${key} cannot be larger than 512 characters.`) new Error( `Key Validation Error: ${key} cannot be larger than 512 characters.` ) ); await restoreImpl(new StateProvider()); expect(cache.restoreCache).toHaveBeenCalledTimes(1); Loading Loading @@ -336,7 +335,10 @@ test("restore with lookup-only set", async () => { test("restore failure with earlyExit should call process exit", async () => { testUtils.setInput(Inputs.Path, "node_modules"); const processExitMock = jest.spyOn(process, "exit").mockImplementation((() => {}) as any); const processExitMock = jest .spyOn(process, "exit") // eslint-disable-next-line @typescript-eslint/no-explicit-any .mockImplementation((() => {}) as any); await restoreImpl(new StateProvider(), true); Loading
__tests__/restoreOnly.test.ts +8 −8 Changes for __tests__/restoreOnly.test.ts: 8 added lines, 8 removed lines. Original line number Diff line number Diff line import { jest, test, expect, beforeEach, afterEach } from "@jest/globals"; import { afterEach, beforeEach, expect, jest, test } from "@jest/globals"; // Mock @actions/core jest.unstable_mockModule("@actions/core", () => ({ Loading Loading @@ -50,13 +50,10 @@ beforeEach(() => { (core.getInput as jest.Mock).mockImplementation( (name: string, options?: { required?: boolean }) => { const val = process.env[ `INPUT_${name.replace(/ /g, "_").toUpperCase()}` ] || ""; process.env[`INPUT_${name.replace(/ /g, "_").toUpperCase()}`] || ""; if (options && options.required && !val) { throw new Error( `Input required and not supplied: ${name}` ); throw new Error(`Input required and not supplied: ${name}`); } return val.trim(); } Loading Loading @@ -167,7 +164,10 @@ test("restore with cache found for restore key", async () => { expect(cache.restoreCache).toHaveBeenCalledTimes(1); expect(core.setOutput).toHaveBeenCalledWith("cache-primary-key", key); expect(core.setOutput).toHaveBeenCalledWith("cache-hit", "false"); expect(core.setOutput).toHaveBeenCalledWith("cache-matched-key", restoreKey); expect(core.setOutput).toHaveBeenCalledWith( "cache-matched-key", restoreKey ); expect(core.setOutput).toHaveBeenCalledTimes(3); expect(core.info).toHaveBeenCalledWith( `Cache restored from key: ${restoreKey}` Loading
__tests__/save.test.ts +4 −7 Changes for __tests__/save.test.ts: 4 added lines, 7 removed lines. Original line number Diff line number Diff line import { jest, test, expect, beforeEach, afterEach } from "@jest/globals"; import { afterEach, beforeEach, expect, jest, test } from "@jest/globals"; // Mock @actions/core jest.unstable_mockModule("@actions/core", () => ({ Loading Loading @@ -50,13 +50,10 @@ beforeEach(() => { (core.getInput as jest.Mock).mockImplementation( (name: string, options?: { required?: boolean }) => { const val = process.env[ `INPUT_${name.replace(/ /g, "_").toUpperCase()}` ] || ""; process.env[`INPUT_${name.replace(/ /g, "_").toUpperCase()}`] || ""; if (options && options.required && !val) { throw new Error( `Input required and not supplied: ${name}` ); throw new Error(`Input required and not supplied: ${name}`); } return val.trim(); } Loading