99import { expect } from "chai" ;
1010import proxyquire from "proxyquire" ;
1111import sinon from "sinon" ;
12+ import { consoleStub } from "../../testResources/setup" ;
1213
1314const pq = proxyquire . noCallThru ( ) ;
1415
@@ -681,17 +682,17 @@ describe("oasDiffChangelog", () => {
681682
682683 it ( "should normalize directory names when normalize-directory-names flag is passed" , async ( ) => {
683684 const execStub = createMockExec ( ) ;
684- execStub . onSecondCall ( ) . callsArgWith ( 1 , null , "changes in api-v1 " , "" ) ;
685+ execStub . onSecondCall ( ) . callsArgWith ( 1 , null , "changes in api-1 " , "" ) ;
685686
686687 const fsStub = createMockFs ( ) ;
687688 // Setup directory structure with versioned directory names
688689 setupDirectoryStructure ( fsStub , [
689- { path : "base" , contents : [ "api-v1 .0.16" , "api-v2 .1.5" ] } ,
690- { path : "base/api-v1 .0.16" , contents : [ "exchange.json" , "spec.yaml" ] } ,
691- { path : "base/api-v2 .1.5" , contents : [ "exchange.json" , "spec.yaml" ] } ,
692- { path : "new" , contents : [ "api-v1 .0.17" , "api-v2 .1.6" ] } ,
693- { path : "new/api-v1 .0.17" , contents : [ "exchange.json" , "spec.yaml" ] } ,
694- { path : "new/api-v2 .1.6" , contents : [ "exchange.json" , "spec.yaml" ] } ,
690+ { path : "base" , contents : [ "api-1 .0.16" , "api-2 .1.5" ] } ,
691+ { path : "base/api-1 .0.16" , contents : [ "exchange.json" , "spec.yaml" ] } ,
692+ { path : "base/api-2 .1.5" , contents : [ "exchange.json" , "spec.yaml" ] } ,
693+ { path : "new" , contents : [ "api-1 .0.17" , "api-2 .1.6" ] } ,
694+ { path : "new/api-1 .0.17" , contents : [ "exchange.json" , "spec.yaml" ] } ,
695+ { path : "new/api-2 .1.6" , contents : [ "exchange.json" , "spec.yaml" ] } ,
695696 ] ) ;
696697
697698 const oasDiff = createOasDiffProxy ( execStub , fsStub ) ;
@@ -713,8 +714,19 @@ describe("oasDiffChangelog", () => {
713714 expect ( writtenContent ) . to . be . a ( "string" ) ;
714715 expect ( writtenContent . length ) . to . be . greaterThan ( 0 ) ;
715716
716- // The test verifies that the normalize-directory-names flag is being processed
717- // and that the function completes successfully with the flag enabled
717+ // Verify that the console.log stub captured the "Processing directory pair" message
718+ expect ( consoleStub . called ) . to . be . true ;
719+ const processingMessage = consoleStub . args . find (
720+ // verify that the message contains the normalized directory name
721+ ( args ) => args [ 0 ] === "Processing directory pair: api-1"
722+ ) ;
723+ expect ( processingMessage ) . to . not . be . undefined ;
724+
725+ // Also verify that api-2 is being processed
726+ const processingMessage2 = consoleStub . args . find (
727+ ( args ) => args [ 0 ] === "Processing directory pair: api-2"
728+ ) ;
729+ expect ( processingMessage2 ) . to . not . be . undefined ;
718730 } ) ;
719731
720732 it ( "should handle fs.readdir error in findYamlFiles function" , async ( ) => {
0 commit comments