Use @actions/[email protected] to invoke GraphQL for GHES compatibility

This commit is contained in:
eric sciple
2020-05-13 20:24:25 -04:00
parent 9bf8ee6742
commit f4a606f9ac
5 changed files with 82 additions and 68 deletions
+7 -14
View File
@@ -3,18 +3,9 @@ import {
RequestParameters
} from '@octokit/graphql/dist-types/types'
import * as Graphql from '@octokit/graphql'
import * as Graphql from '../../src/version/graphql'
import {GetVersionsQueryResponse} from '../../src/version'
import SpyInstance = jest.SpyInstance
export function mockGraphql(): SpyInstance<
Promise<GraphQlQueryResponseData>,
[string, (RequestParameters | undefined)?]
> {
return jest.spyOn(Graphql, 'graphql')
}
export function getMockedOldestQueryResponse(
numVersions: number
): GetVersionsQueryResponse {
@@ -49,8 +40,10 @@ export function getMockedOldestQueryResponse(
export function mockOldestQueryResponse(
numVersions: number
): ReturnType<typeof mockGraphql> {
return mockGraphql().mockResolvedValue(
getMockedOldestQueryResponse(numVersions)
)
) {
const response = new Promise((resolve) => {
resolve(getMockedOldestQueryResponse(numVersions))
}) as Promise<GraphQlQueryResponseData>
jest.spyOn(Graphql, 'graphql').mockImplementation(
(token: string, query: string, parameters: RequestParameters) => response)
}