|
8 | 8 | // eslint-disable-next-line jest/no-commented-out-tests |
9 | 9 | import { jest } from '@jest/globals' |
10 | 10 | import * as core from '../__fixtures__/core.js' |
| 11 | +//import { InputOptions } from "@actions/core"; |
11 | 12 |
|
12 | 13 | // Mocks should be declared before the module being tested is imported. |
13 | 14 | jest.unstable_mockModule('@actions/core', () => core) |
14 | 15 |
|
15 | 16 | // The module being tested should be imported dynamically. This ensures that the |
16 | | -// mocks are used in place of any actual dependencies. |
17 | | -//const { run } = await import('../src/main.js') |
| 17 | +//mocks are used in place of any actual dependencies. |
| 18 | +const { run } = await import('../src/main.js') |
18 | 19 |
|
19 | 20 | describe('main.ts', () => { |
20 | | - /*beforeEach(() => { |
| 21 | + beforeEach(() => { |
21 | 22 | // Set the action's inputs as return values from core.getInput(). |
22 | | - core.getInput.mockImplementation(() => '500') |
| 23 | + core.getInput.mockImplementation((name: string) => { |
| 24 | + if (name === 'schemaPath') return 'schema.json' |
| 25 | + else if (name === 'validate') return 'true' |
| 26 | + else return 'true' |
| 27 | + }) |
23 | 28 |
|
24 | 29 | // Mock the wait function so that it does not actually wait. |
25 | | - wait.mockImplementation(() => Promise.resolve('done!')) |
| 30 | + //wait.mockImplementation(() => Promise.resolve('done!')) |
26 | 31 | }) |
| 32 | + |
27 | 33 | afterEach(() => { |
28 | 34 | jest.resetAllMocks() |
29 | 35 | }) |
30 | | - it('Sets the time output', async () => { |
| 36 | + it('Sets the schema path', async () => { |
31 | 37 | await run() |
32 | 38 |
|
33 | 39 | // Verify the time output was set. |
34 | 40 | expect(core.setOutput).toHaveBeenNthCalledWith( |
35 | 41 | 1, |
36 | | - 'time', |
| 42 | + 'message', |
37 | 43 | // Simple regex to match a time string in the format HH:MM:SS. |
38 | | - expect.stringMatching(/^\d{2}:\d{2}:\d{2}/) |
| 44 | + expect.stringMatching(/^JSON Schema Check Results/) |
39 | 45 | ) |
40 | 46 | }) |
| 47 | + /* |
41 | 48 | it('Sets a failed status', async () => { |
42 | 49 | // Clear the getInput mock and return an invalid value. |
43 | 50 | core.getInput.mockClear().mockReturnValueOnce('this is not a number') |
|
0 commit comments