44 * SPDX-License-Identifier: Apache-2.0
55 */
66
7- import { describe , it , expect , vi , beforeEach } from 'vitest' ;
7+ import { vi , describe , it , expect , beforeEach } from 'vitest' ;
88
99const mockInstallSkill = vi . hoisted ( ( ) => vi . fn ( ) ) ;
1010const mockRequestConsentNonInteractive = vi . hoisted ( ( ) => vi . fn ( ) ) ;
@@ -19,11 +19,17 @@ vi.mock('../../config/extensions/consent.js', () => ({
1919 skillsConsentString : mockSkillsConsentString ,
2020} ) ) ;
2121
22+ const { debugLogger, emitConsoleLog } = await vi . hoisted ( async ( ) => {
23+ const { createMockDebugLogger } = await import (
24+ '../../test-utils/mockDebugLogger.js'
25+ ) ;
26+ return createMockDebugLogger ( { stripAnsi : true } ) ;
27+ } ) ;
28+
2229vi . mock ( '@google/gemini-cli-core' , ( ) => ( {
23- debugLogger : { log : vi . fn ( ) , error : vi . fn ( ) } ,
30+ debugLogger,
2431} ) ) ;
2532
26- import { debugLogger } from '@google/gemini-cli-core' ;
2733import { handleInstall , installCommand } from './install.js' ;
2834
2935describe ( 'skill install command' , ( ) => {
@@ -63,10 +69,12 @@ describe('skill install command', () => {
6369 expect . any ( Function ) ,
6470 expect . any ( Function ) ,
6571 ) ;
66- expect ( debugLogger . log ) . toHaveBeenCalledWith (
72+ expect ( emitConsoleLog ) . toHaveBeenCalledWith (
73+ 'log' ,
6774 expect . stringContaining ( 'Successfully installed skill: test-skill' ) ,
6875 ) ;
69- expect ( debugLogger . log ) . toHaveBeenCalledWith (
76+ expect ( emitConsoleLog ) . toHaveBeenCalledWith (
77+ 'log' ,
7078 expect . stringContaining ( 'location: /mock/user/skills/test-skill' ) ,
7179 ) ;
7280 expect ( mockRequestConsentNonInteractive ) . toHaveBeenCalledWith (
@@ -86,10 +94,11 @@ describe('skill install command', () => {
8694 } ) ;
8795
8896 expect ( mockRequestConsentNonInteractive ) . not . toHaveBeenCalled ( ) ;
89- expect ( debugLogger . log ) . toHaveBeenCalledWith (
97+ expect ( emitConsoleLog ) . toHaveBeenCalledWith (
98+ 'log' ,
9099 'You have consented to the following:' ,
91100 ) ;
92- expect ( debugLogger . log ) . toHaveBeenCalledWith ( 'Mock Consent String' ) ;
101+ expect ( emitConsoleLog ) . toHaveBeenCalledWith ( 'log' , 'Mock Consent String' ) ;
93102 expect ( mockInstallSkill ) . toHaveBeenCalled ( ) ;
94103 } ) ;
95104
@@ -106,7 +115,8 @@ describe('skill install command', () => {
106115 source : 'https://example.com/repo.git' ,
107116 } ) ;
108117
109- expect ( debugLogger . error ) . toHaveBeenCalledWith (
118+ expect ( emitConsoleLog ) . toHaveBeenCalledWith (
119+ 'error' ,
110120 'Skill installation cancelled by user.' ,
111121 ) ;
112122 expect ( process . exit ) . toHaveBeenCalledWith ( 1 ) ;
@@ -137,7 +147,7 @@ describe('skill install command', () => {
137147
138148 await handleInstall ( { source : '/local/path' } ) ;
139149
140- expect ( debugLogger . error ) . toHaveBeenCalledWith ( 'Install failed' ) ;
150+ expect ( emitConsoleLog ) . toHaveBeenCalledWith ( 'error' , 'Install failed' ) ;
141151 expect ( process . exit ) . toHaveBeenCalledWith ( 1 ) ;
142152 } ) ;
143153} ) ;
0 commit comments