test(plugin-handlers): update all plugin handler tests
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test"
|
||||
import { afterEach, beforeEach, describe, expect, spyOn, test, mock } from "bun:test"
|
||||
|
||||
import type { OhMyOpenCodeConfig } from "../config"
|
||||
import { createConfigHandler } from "./config-handler"
|
||||
import * as agentConfigHandler from "./agent-config-handler"
|
||||
import * as commandConfigHandler from "./command-config-handler"
|
||||
import * as mcpConfigHandler from "./mcp-config-handler"
|
||||
@@ -17,8 +16,26 @@ let applyToolConfigSpy: ReturnType<typeof spyOn>
|
||||
let applyMcpConfigSpy: ReturnType<typeof spyOn>
|
||||
let applyCommandConfigSpy: ReturnType<typeof spyOn>
|
||||
let applyProviderConfigSpy: ReturnType<typeof spyOn>
|
||||
let createConfigHandler: (typeof import("./config-handler"))["createConfigHandler"]
|
||||
|
||||
async function importFreshConfigHandlerModule(): Promise<typeof import("./config-handler")> {
|
||||
return import(`./config-handler?test=${Date.now()}-${Math.random()}`)
|
||||
}
|
||||
|
||||
function createPluginConfig(overrides: Partial<OhMyOpenCodeConfig> = {}): OhMyOpenCodeConfig {
|
||||
return {
|
||||
git_master: {
|
||||
commit_footer: true,
|
||||
include_co_authored_by: true,
|
||||
git_env_prefix: "GIT_MASTER=1",
|
||||
},
|
||||
...overrides,
|
||||
}
|
||||
}
|
||||
|
||||
beforeEach(async () => {
|
||||
mock.restore()
|
||||
|
||||
beforeEach(() => {
|
||||
logSpy = spyOn(shared, "log").mockImplementation(() => {})
|
||||
loadPluginComponentsSpy = spyOn(
|
||||
pluginComponentsLoader,
|
||||
@@ -47,6 +64,7 @@ beforeEach(() => {
|
||||
providerConfigHandler,
|
||||
"applyProviderConfig",
|
||||
).mockImplementation(() => {})
|
||||
;({ createConfigHandler } = await importFreshConfigHandlerModule())
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
@@ -57,12 +75,13 @@ afterEach(() => {
|
||||
applyMcpConfigSpy.mockRestore()
|
||||
applyCommandConfigSpy.mockRestore()
|
||||
applyProviderConfigSpy.mockRestore()
|
||||
mock.restore()
|
||||
})
|
||||
|
||||
describe("createConfigHandler formatter pass-through", () => {
|
||||
test("preserves formatter object configured in opencode config", async () => {
|
||||
// given
|
||||
const pluginConfig: OhMyOpenCodeConfig = {}
|
||||
const pluginConfig = createPluginConfig()
|
||||
const formatterConfig = {
|
||||
prettier: {
|
||||
command: ["prettier", "--write"],
|
||||
@@ -98,7 +117,7 @@ describe("createConfigHandler formatter pass-through", () => {
|
||||
|
||||
test("preserves formatter=false configured in opencode config", async () => {
|
||||
// given
|
||||
const pluginConfig: OhMyOpenCodeConfig = {}
|
||||
const pluginConfig = createPluginConfig()
|
||||
const config: Record<string, unknown> = {
|
||||
formatter: false,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user