From 506fd53fb1a9a7d2506c5308a8fb583865318e46 Mon Sep 17 00:00:00 2001 From: Branden Cash Date: Tue, 20 Feb 2024 14:59:07 -0700 Subject: [PATCH] test: type the @actions/core spy/mock from the actual implementations This allows the mockImplementation calls to automatically be typed based on the official @actions/core type definitions rather than having to define them manually. Signed-off-by: Branden Cash --- __tests__/main.test.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 30efdfb..ce373fb 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -16,11 +16,11 @@ const runMock = jest.spyOn(main, 'run') const timeRegex = /^\d{2}:\d{2}:\d{2}/ // Mock the GitHub Actions core library -let debugMock: jest.SpyInstance -let errorMock: jest.SpyInstance -let getInputMock: jest.SpyInstance -let setFailedMock: jest.SpyInstance -let setOutputMock: jest.SpyInstance +let debugMock: jest.SpiedFunction +let errorMock: jest.SpiedFunction +let getInputMock: jest.SpiedFunction +let setFailedMock: jest.SpiedFunction +let setOutputMock: jest.SpiedFunction describe('action', () => { beforeEach(() => { @@ -35,7 +35,7 @@ describe('action', () => { it('sets the time output', async () => { // Set the action's inputs as return values from core.getInput() - getInputMock.mockImplementation((name: string): string => { + getInputMock.mockImplementation(name => { switch (name) { case 'milliseconds': return '500' @@ -67,7 +67,7 @@ describe('action', () => { it('sets a failed status', async () => { // Set the action's inputs as return values from core.getInput() - getInputMock.mockImplementation((name: string): string => { + getInputMock.mockImplementation(name => { switch (name) { case 'milliseconds': return 'this is not a number'