54b504899d
* delete package versions action v1 * updated action for build and smoke test * test and error message update * test fix * ci testing * ci testing * ci testing * ci testing * ci test * ci testing * ci test name * docs * docs * docs * test * test * test * docs * usage doc * doc * docs * format test * doc update * doc test * formatting check * scenario update * usage update * format * test * test * test * test * test * table test * test * format update * links * test * test * test * test * test * docs update * test * formatting * fix broken links * doc update * test * table test * test * test * test * test * test * test * test * test * test * test * doc test * test * test * test * test * test * test * test t * test * test * test * test * test * test * docs * doc update
57 lines
1.1 KiB
TypeScript
57 lines
1.1 KiB
TypeScript
import {
|
|
GraphQlQueryResponseData,
|
|
RequestParameters
|
|
} from '@octokit/graphql/dist-types/types'
|
|
|
|
import * as Graphql from '@octokit/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 {
|
|
const versions = []
|
|
|
|
for (let i = 1; i <= numVersions; ++i) {
|
|
versions.push({
|
|
node: {
|
|
id: i.toString(),
|
|
version: `${i}.0.0`
|
|
}
|
|
})
|
|
}
|
|
|
|
return {
|
|
repository: {
|
|
packages: {
|
|
edges: [
|
|
{
|
|
node: {
|
|
name: 'test',
|
|
versions: {
|
|
edges: versions.reverse()
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
export function mockOldestQueryResponse(
|
|
numVersions: number
|
|
): ReturnType<typeof mockGraphql> {
|
|
return mockGraphql().mockResolvedValue(
|
|
getMockedOldestQueryResponse(numVersions)
|
|
)
|
|
}
|