1
0
mirror of synced 2025-12-19 18:10:59 -05:00
Files
docs/tests/helpers/action-mocks.js
Evan Bonsignori 7b4429418b Migrate links check to JS pattern (#30175)
Co-authored-by: Sarah Schneider <sarahs@users.noreply.github.com>
Co-authored-by: Peter Bengtsson <peterbe@github.com>
2022-10-17 21:47:21 +00:00

51 lines
913 B
JavaScript

import { jest } from '@jest/globals'
export function coreMock() {
return {
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(console.error),
setOutput: jest.fn(),
}
}
export function octokitMock({ requestMock, listForRepoMock } = {}) {
return {
request: jest.fn(requestMock),
rest: {
issues: {
listForRepo: jest.fn(listForRepoMock),
createComment: jest.fn(),
update: jest.fn(),
},
},
}
}
export function cheerioMock(argToValueMap) {
return {
load: jest.fn(async () => {
return (arg) => {
return argToValueMap[arg]
}
}),
}
}
export function gotMock({ status } = {}) {
return jest.fn(async () => {
if (status < 200 || status >= 400) {
throw new Error({
status,
})
}
return new Error({
status,
})
})
}
export function uploadArtifactMock() {
return jest.fn()
}