test(auto-update-checker): type background update bun install mock

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-03-11 17:51:31 +09:00
parent 522ae81960
commit de2b073fce
3 changed files with 153 additions and 61 deletions
@@ -1,6 +1,12 @@
import type { PluginInput } from "@opencode-ai/plugin"
/// <reference types="bun-types" />
import type { BunInstallResult } from "../../../cli/config-manager"
import { beforeEach, describe, expect, it, mock } from "bun:test"
type PluginInput = {
directory: string
}
type PluginEntry = {
entry: string
isPinned: boolean
@@ -31,7 +37,7 @@ const mockSyncCachePackageJsonToIntent = mock((_pluginEntry: PluginEntry) => {
const mockInvalidatePackage = mock((_packageName: string) => {
operationOrder.push("invalidate")
})
const mockRunBunInstallWithDetails = mock(async () => ({ success: true }))
const mockRunBunInstallWithDetails = mock(async (): Promise<BunInstallResult> => ({ success: true }))
const mockShowUpdateAvailableToast = mock(
async (_ctx: PluginInput, _latestVersion: string, _getToastMessage: ToastMessageGetter): Promise<void> => {}
)
@@ -90,6 +96,13 @@ describe("runBackgroundUpdateCheck", () => {
operationOrder.length = 0
mockSyncCachePackageJsonToIntent.mockImplementation((_pluginEntry: PluginEntry) => {
operationOrder.push("sync")
})
mockInvalidatePackage.mockImplementation((_packageName: string) => {
operationOrder.push("invalidate")
})
pluginEntry = createPluginEntry()
mockFindPluginEntry.mockReturnValue(pluginEntry)
mockGetCachedVersion.mockReturnValue("3.4.0")