Skip to content

Commit

Permalink
fix tests errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bgawkuc committed May 28, 2024
1 parent 6ae0cca commit 2cbb545
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/unit/postTestBuildComment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(<T, TData>(endpoint: (params: Record<string, T>) => Promise<{data: TData}>, params: Record<string, T>) =>
endpoint(params).then((response) => response.data),
);
function mockImplementation<T, TData>(endpoint: (params: Record<string, T>) => Promise<{data: TData}>, params: Record<string, T>) {
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: {
Expand Down

0 comments on commit 2cbb545

Please sign in to comment.