test: move tests and fixtures to top-level "tests" directory (#29)

This commit is contained in:
2025-10-29 11:09:22 +00:00
committed by GitHub
parent 73e6309596
commit 2b1c01b3ed
8 changed files with 10 additions and 11 deletions

10
tests/fixtures/core.ts vendored Normal file
View 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
View 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
View 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

File diff suppressed because it is too large Load Diff