test: make unsafe test coercion explicit
Move test coercion out of a hidden global and require each test to import the helper so review tools and runtime scripts can see the unsafe boundary. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -5,6 +5,7 @@ import { join } from "node:path"
|
||||
import { install } from "./install"
|
||||
import * as configManager from "./config-manager"
|
||||
import type { InstallArgs } from "./types"
|
||||
import { unsafeTestValue } from "../../test-support/unsafe-test-value"
|
||||
|
||||
// Mock console methods to capture output
|
||||
const mockConsoleLog = mock(() => {})
|
||||
@@ -57,7 +58,7 @@ describe("install CLI - binary check behavior", () => {
|
||||
getOpenCodeVersionSpy = spyOn(configManager, "getOpenCodeVersion").mockResolvedValue(null)
|
||||
|
||||
// given mock npm fetch
|
||||
globalThis.fetch = testCoerce<typeof fetch>(mock(() =>
|
||||
globalThis.fetch = unsafeTestValue<typeof fetch>(mock(() =>
|
||||
Promise.resolve({
|
||||
ok: true,
|
||||
json: () => Promise.resolve({ latest: "3.0.0" }),
|
||||
@@ -92,7 +93,7 @@ describe("install CLI - binary check behavior", () => {
|
||||
getOpenCodeVersionSpy = spyOn(configManager, "getOpenCodeVersion").mockResolvedValue(null)
|
||||
|
||||
// given mock npm fetch
|
||||
globalThis.fetch = testCoerce<typeof fetch>(mock(() =>
|
||||
globalThis.fetch = unsafeTestValue<typeof fetch>(mock(() =>
|
||||
Promise.resolve({
|
||||
ok: true,
|
||||
json: () => Promise.resolve({ latest: "3.0.0" }),
|
||||
@@ -131,7 +132,7 @@ describe("install CLI - binary check behavior", () => {
|
||||
getOpenCodeVersionSpy = spyOn(configManager, "getOpenCodeVersion").mockResolvedValue("1.4.0")
|
||||
|
||||
// given mock npm fetch
|
||||
globalThis.fetch = testCoerce<typeof fetch>(mock(() =>
|
||||
globalThis.fetch = unsafeTestValue<typeof fetch>(mock(() =>
|
||||
Promise.resolve({
|
||||
ok: true,
|
||||
json: () => Promise.resolve({ latest: "3.0.0" }),
|
||||
|
||||
Reference in New Issue
Block a user