mirror of
https://github.com/jimeh/update-tags-action.git
synced 2026-02-19 09:36:41 +00:00
test: move tests and fixtures to top-level "tests" directory (#29)
This commit is contained in:
10
tests/fixtures/core.ts
vendored
Normal file
10
tests/fixtures/core.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import type * as core from '@actions/core'
|
||||
import { jest } from '@jest/globals'
|
||||
|
||||
export const debug = jest.fn<typeof core.debug>()
|
||||
export const error = jest.fn<typeof core.error>()
|
||||
export const info = jest.fn<typeof core.info>()
|
||||
export const getInput = jest.fn<typeof core.getInput>()
|
||||
export const setOutput = jest.fn<typeof core.setOutput>()
|
||||
export const setFailed = jest.fn<typeof core.setFailed>()
|
||||
export const warning = jest.fn<typeof core.warning>()
|
||||
13
tests/fixtures/csv-parse.ts
vendored
Normal file
13
tests/fixtures/csv-parse.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { jest } from '@jest/globals'
|
||||
import { parse as realParse } from 'csv-parse/sync'
|
||||
|
||||
export const parse = jest.fn()
|
||||
|
||||
// Helper to reset to real implementation after jest.resetAllMocks()
|
||||
export const resetToRealImplementation = (): void => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
parse.mockImplementation(realParse as any)
|
||||
}
|
||||
|
||||
// Initialize with real implementation
|
||||
resetToRealImplementation()
|
||||
27
tests/fixtures/github.ts
vendored
Normal file
27
tests/fixtures/github.ts
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import { jest } from '@jest/globals'
|
||||
|
||||
export const mockOctokit = {
|
||||
rest: {
|
||||
git: {
|
||||
getRef: jest.fn<(args: unknown) => Promise<unknown>>(),
|
||||
createRef: jest.fn<(args: unknown) => Promise<unknown>>(),
|
||||
updateRef: jest.fn<(args: unknown) => Promise<unknown>>(),
|
||||
createTag: jest.fn<(args: unknown) => Promise<unknown>>(),
|
||||
getTag: jest.fn<(args: unknown) => Promise<unknown>>()
|
||||
},
|
||||
repos: {
|
||||
getCommit: jest.fn<(args: unknown) => Promise<unknown>>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const getOctokit = jest
|
||||
.fn<(token: string) => typeof mockOctokit>()
|
||||
.mockReturnValue(mockOctokit)
|
||||
|
||||
export const context = {
|
||||
repo: {
|
||||
owner: 'test-owner',
|
||||
repo: 'test-repo'
|
||||
}
|
||||
}
|
||||
1102
tests/main.test.ts
Normal file
1102
tests/main.test.ts
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user