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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user