From 2cbb5457f48c4f72827433d7af106e4c8fe6c7e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barbara=20Gawe=C5=82-Kucab?= Date: Tue, 28 May 2024 17:21:48 +0200 Subject: [PATCH] fix tests errors --- tests/unit/postTestBuildComment.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/unit/postTestBuildComment.ts b/tests/unit/postTestBuildComment.ts index 310809cd4f83..6a7f8182be1e 100644 --- a/tests/unit/postTestBuildComment.ts +++ b/tests/unit/postTestBuildComment.ts @@ -16,13 +16,17 @@ jest.spyOn(GithubUtils, 'octokit', 'get').mockReturnValue({ }, } as RestEndpointMethods); -// @ts-expect-error -- it's a static getter -jest.spyOn(GithubUtils, 'paginate', 'get').mockReturnValue((endpoint: (params: Record) => Promise<{data: TData}>, params: Record) => - endpoint(params).then((response) => response.data), -); +function mockImplementation(endpoint: (params: Record) => Promise<{data: TData}>, params: Record) { + return endpoint(params).then((response) => response.data); +} -// @ts-expect-error -- it's a static getter -jest.spyOn(GithubUtils, 'graphql', 'get').mockReturnValue(mockGraphql); +Object.defineProperty(GithubUtils, 'paginate', { + get: () => mockImplementation, +}); + +Object.defineProperty(GithubUtils, 'graphql', { + get: () => mockGraphql, +}); jest.mock('@actions/github', () => ({ context: {