Browse Source

test: stabilize shared mocks

Alvin Unreal 3 weeks ago
parent
commit
6f112a567b
3 changed files with 16 additions and 9 deletions
  1. 4 2
      src/cli/install.test.ts
  2. 1 1
      src/hooks/auto-update-checker/index.test.ts
  3. 11 6
      src/utils/env.test.ts

+ 4 - 2
src/cli/install.test.ts

@@ -120,8 +120,10 @@ mock.module('./background-subagents', () => {
     ...actualBackgroundSubagents,
     isBackgroundSubagentsEnabled: (env?: string) =>
       enableInstallMocks ? true : originalIsBackgroundSubagentsEnabled(env),
-    detectBackgroundSubagentsTarget: () =>
-      enableInstallMocks ? '/path' : originalDetectBackgroundSubagentsTarget(),
+    detectBackgroundSubagentsTarget: (env?: NodeJS.ProcessEnv) =>
+      enableInstallMocks
+        ? '/path'
+        : originalDetectBackgroundSubagentsTarget(env),
     expandHomePath: (p: string) =>
       enableInstallMocks ? p : originalExpandHomePath(p),
     getBackgroundSubagentsBlock: (target: string) =>

+ 1 - 1
src/hooks/auto-update-checker/index.test.ts

@@ -984,7 +984,7 @@ describe('auto-update-checker/index', () => {
     const hook = createAutoUpdateCheckerHook(ctx as never);
     hook.event({ event: { type: 'session.created', properties: {} } });
 
-    await waitForCalls(logMock, 1);
+    await waitForCalls(skillSyncMocks.syncBundledSkillsFromPackage, 1);
 
     expect(skillSyncMocks.syncBundledSkillsFromPackage).toHaveBeenCalledWith(
       '/tmp/opencode',

+ 11 - 6
src/utils/env.test.ts

@@ -10,12 +10,17 @@ describe('isTruthyEnvValue', () => {
     expect(isTruthyEnvValue(value)).toBe(true);
   });
 
-  test.each([undefined, '', '0', 'false', 'no', 'off', 'anything'])(
-    '%p is not truthy',
-    (value) => {
-      expect(isTruthyEnvValue(value)).toBe(false);
-    },
-  );
+  test.each([
+    undefined,
+    '',
+    '0',
+    'false',
+    'no',
+    'off',
+    'anything',
+  ])('%p is not truthy', (value) => {
+    expect(isTruthyEnvValue(value)).toBe(false);
+  });
 });
 
 describe('isPluginDisabledByEnv', () => {