chore: use github's shared prettier-config

This commit is contained in:
Marais Rossouw
2025-07-24 19:11:15 +10:00
parent a2235c5511
commit 7e2aa19f3b
26 changed files with 351 additions and 559 deletions
+17 -31
View File
@@ -1,12 +1,4 @@
import {
describe,
it,
expect,
beforeEach,
vi,
type MockedFunction,
type Mock
} from 'vitest'
import {describe, it, expect, beforeEach, vi, type MockedFunction, type Mock} from 'vitest'
import * as core from '../__fixtures__/core.js'
// Create fs mocks
@@ -26,25 +18,25 @@ const mockConnectToGitHubMCP = vi.fn()
vi.mock('fs', () => ({
existsSync: mockExistsSync,
readFileSync: mockReadFileSync,
writeFileSync: mockWriteFileSync
writeFileSync: mockWriteFileSync,
}))
// Mock the inference functions
vi.mock('../src/inference.js', () => ({
simpleInference: mockSimpleInference,
mcpInference: mockMcpInference
mcpInference: mockMcpInference,
}))
// Mock the MCP connection
vi.mock('../src/mcp.js', () => ({
connectToGitHubMCP: mockConnectToGitHubMCP
connectToGitHubMCP: mockConnectToGitHubMCP,
}))
vi.mock('@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')
const {run} = await import('../src/main.js')
describe('main.ts - prompt.yml integration', () => {
beforeEach(() => {
@@ -119,29 +111,23 @@ model: openai/gpt-4o
messages: [
{
role: 'system',
content: 'Be as concise as possible'
content: 'Be as concise as possible',
},
{
role: 'user',
content: 'Compare cats and dogs, please'
}
content: 'Compare cats and dogs, please',
},
],
modelName: 'openai/gpt-4o',
maxTokens: 200,
endpoint: 'https://models.github.ai/inference',
token: 'test-token'
})
token: 'test-token',
}),
)
// Verify outputs were set
expect(core.setOutput).toHaveBeenCalledWith(
'response',
'Mocked AI response'
)
expect(core.setOutput).toHaveBeenCalledWith(
'response-file',
expect.any(String)
)
expect(core.setOutput).toHaveBeenCalledWith('response', 'Mocked AI response')
expect(core.setOutput).toHaveBeenCalledWith('response-file', expect.any(String))
})
it('should fall back to legacy format when not using prompt YAML', async () => {
@@ -173,18 +159,18 @@ model: openai/gpt-4o
messages: [
{
role: 'system',
content: 'You are helpful'
content: 'You are helpful',
},
{
role: 'user',
content: 'Hello, world!'
}
content: 'Hello, world!',
},
],
modelName: 'openai/gpt-4o',
maxTokens: 200,
endpoint: 'https://models.github.ai/inference',
token: 'test-token'
})
token: 'test-token',
}),
)
})
})