@@ -10,7 +10,7 @@ const { spawn } = require('child_process');
1010
1111jest . mock ( 'fs' ) ;
1212
13- const AGENT_SCRIPT = path . join ( __dirname , '../generate-plugin.agent.js' ) ;
13+ const AGENT_SCRIPT = path . join ( __dirname , '../agents/ generate-plugin.agent.js' ) ;
1414
1515/* eslint-disable jsdoc/check-line-alignment */
1616/**
@@ -59,6 +59,10 @@ describe('generate-plugin.agent.js', () => {
5959 fs . writeFileSync = jest . fn ( ) ;
6060 fs . existsSync = jest . fn ( ) . mockReturnValue ( false ) ;
6161 fs . readFileSync = jest . fn ( ) ;
62+ console . log . mockClear ( ) ;
63+ console . info . mockClear ( ) ;
64+ console . warn . mockClear ( ) ;
65+ console . error . mockClear ( ) ;
6266 } ) ;
6367
6468 describe ( 'Command Line Arguments' , ( ) => {
@@ -68,13 +72,15 @@ describe('generate-plugin.agent.js', () => {
6872 expect ( result . stdout ) . toContain ( 'Usage:' ) ;
6973 expect ( result . stdout ) . toContain ( 'Interactive:' ) ;
7074 expect ( result . stdout ) . toContain ( 'With JSON:' ) ;
75+ expect ( console ) . toHaveLogged ( ) ;
7176 } ) ;
7277
7378 it ( 'prints the schema when --schema is supplied' , async ( ) => {
7479 const result = await runAgent ( [ '--schema' ] ) ;
7580 expect ( result . code ) . toBe ( 0 ) ;
7681 expect ( result . stdout ) . toContain ( '"$schema"' ) ;
7782 expect ( result . stdout ) . toContain ( '"type": "object"' ) ;
83+ expect ( console ) . toHaveLogged ( ) ;
7884 } ) ;
7985 } ) ;
8086
@@ -89,6 +95,7 @@ describe('generate-plugin.agent.js', () => {
8995 const result = await runAgent ( [ '--json' ] , { input : validConfig } ) ;
9096 expect ( result . code ) . toBe ( 0 ) ;
9197 expect ( result . stderr ) . toBe ( '' ) ;
98+ expect ( console ) . toHaveLogged ( ) ;
9299 } ) ;
93100
94101 it ( 'rejects invalid JSON that is provided via stdin' , async ( ) => {
@@ -97,6 +104,7 @@ describe('generate-plugin.agent.js', () => {
97104 } ) ;
98105 expect ( result . code ) . not . toBe ( 0 ) ;
99106 expect ( result . stderr ) . toContain ( 'Invalid JSON' ) ;
107+ expect ( console ) . toHaveErrored ( ) ;
100108 } ) ;
101109
102110 it ( 'validates structure while running in JSON mode' , async ( ) => {
@@ -110,6 +118,7 @@ describe('generate-plugin.agent.js', () => {
110118 } ) ;
111119 expect ( result . code ) . not . toBe ( 0 ) ;
112120 expect ( result . stderr ) . toContain ( 'required' ) ;
121+ expect ( console ) . toHaveErrored ( ) ;
113122 } ) ;
114123 } ) ;
115124
@@ -127,6 +136,7 @@ describe('generate-plugin.agent.js', () => {
127136 result . stdout . includes ( symbol )
128137 ) ;
129138 expect ( hasSuccessIndicator ) . toBe ( true ) ;
139+ expect ( console ) . toHaveLogged ( ) ;
130140 } ) ;
131141
132142 it ( 'fails when the configuration format is invalid' , async ( ) => {
@@ -137,6 +147,7 @@ describe('generate-plugin.agent.js', () => {
137147
138148 const result = await runAgent ( [ '--validate' , invalidConfig ] ) ;
139149 expect ( result . code ) . not . toBe ( 0 ) ;
150+ expect ( console ) . toHaveErrored ( ) ;
140151 } ) ;
141152 } ) ;
142153} ) ;
0 commit comments