Initial commit
Some checks failed
Check Transpiled JavaScript / Check dist/ (push) Successful in 55s
Continuous Integration / TypeScript Tests (push) Successful in 56s
Continuous Integration / GitHub Actions Test (push) Successful in 10s
Lint Codebase / Lint Codebase (push) Failing after 7m55s

This commit is contained in:
2025-01-11 22:39:23 +01:00
commit 3999529881
43 changed files with 38960 additions and 0 deletions

33
__tests__/main.test.ts Normal file
View File

@@ -0,0 +1,33 @@
/**
* Unit tests for the action's main functionality, src/main.ts
*
* To mock dependencies in ESM, you can create fixtures that export mock
* functions and objects. For example, the core module is mocked in this test,
* so that the actual '@actions/core' module is not imported.
*/
import { jest } from '@jest/globals';
import * as core from '../__fixtures__/core.js';
// Mocks should be declared before the module being tested is imported.
jest.unstable_mockModule('@actions/core', () => core);
// The module being tested should be imported dynamically. This ensures that the
// mocks are used in place of any actual dependencies.
const { run } = await import('../src/main.js');
describe('main.ts', () => {
beforeEach(() => {
// Set the action's inputs as return values from core.getInput().
core.getInput.mockImplementation(() => '500');
});
afterEach(() => {
jest.resetAllMocks();
});
it('Reads only one input', async () => {
await run();
expect(core.getInput).toHaveBeenCalledTimes(1);
});
});