2024-02-27 16:47:20 -08:00
|
|
|
/**
|
|
|
|
|
* Unit tests for the action's entrypoint, src/index.ts
|
|
|
|
|
*/
|
2026-02-18 08:52:30 -08:00
|
|
|
import { jest } from '@jest/globals'
|
2024-02-27 16:47:20 -08:00
|
|
|
|
2026-02-18 08:52:30 -08:00
|
|
|
// Mock functions
|
|
|
|
|
const mockRun = jest.fn()
|
|
|
|
|
const mockGetInput = jest.fn()
|
|
|
|
|
const mockGetBooleanInput = jest.fn()
|
2024-02-27 16:47:20 -08:00
|
|
|
|
2026-02-18 08:52:30 -08:00
|
|
|
// Mock @actions/core
|
|
|
|
|
jest.unstable_mockModule('@actions/core', () => ({
|
|
|
|
|
getInput: mockGetInput,
|
|
|
|
|
getBooleanInput: mockGetBooleanInput
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
// Mock ../src/main
|
|
|
|
|
jest.unstable_mockModule('../src/main', () => ({
|
|
|
|
|
run: mockRun
|
|
|
|
|
}))
|
2024-02-27 16:47:20 -08:00
|
|
|
|
|
|
|
|
describe('index', () => {
|
2024-05-24 11:01:44 -07:00
|
|
|
beforeEach(() => {
|
2026-02-18 08:52:30 -08:00
|
|
|
jest.clearAllMocks()
|
|
|
|
|
mockGetBooleanInput.mockReturnValue(false)
|
|
|
|
|
mockGetInput.mockReturnValue('')
|
2024-05-24 11:01:44 -07:00
|
|
|
})
|
2024-02-27 16:47:20 -08:00
|
|
|
|
2026-02-18 08:52:30 -08:00
|
|
|
it('calls run when imported', async () => {
|
|
|
|
|
// Dynamic import after mocking
|
|
|
|
|
await import('../src/index')
|
|
|
|
|
|
|
|
|
|
expect(mockRun).toHaveBeenCalled()
|
2024-02-27 16:47:20 -08:00
|
|
|
})
|
|
|
|
|
})
|