@@ -11,6 +11,26 @@ import sinon from "sinon";
1111const pq = proxyquire . noCallThru ( ) ;
1212
1313describe ( "oasDiffChangelog" , ( ) => {
14+ it ( "should throw an error if oasdiff is not installed" , async ( ) => {
15+ const execStub = sinon . stub ( ) ;
16+ execStub . callsArgWith ( 1 , new Error ( "oasdiff not installed" ) ) ;
17+
18+ const oasDiff = pq ( "./oasDiff" , {
19+ child_process : {
20+ exec : execStub ,
21+ } ,
22+ } ) ;
23+
24+ try {
25+ await oasDiff . checkOasDiffIsInstalled ( ) ;
26+ expect . fail ( "Expected function to throw an error" ) ;
27+ } catch ( error ) {
28+ expect ( error . message ) . to . equal (
29+ "oasdiff is not installed. Install oasdiff according to https://github.com/oasdiff/oasdiff#installation"
30+ ) ;
31+ }
32+ } ) ;
33+
1434 it ( "should execute oasdiff command with correct parameters for single file mode" , async ( ) => {
1535 const execStub = sinon . stub ( ) ;
1636 // Mock the callback-style exec function
@@ -619,24 +639,4 @@ describe("oasDiffChangelog", () => {
619639 expect ( execStub . called ) . to . be . true ;
620640 expect ( result ) . to . equal ( 1 ) ; // Changes should be reported
621641 } ) ;
622-
623- it ( "should throw an error if oasdiff is not installed" , async ( ) => {
624- const execStub = sinon . stub ( ) ;
625- execStub . callsArgWith ( 1 , new Error ( "oasdiff not installed" ) ) ;
626-
627- const oasDiff = pq ( "./oasDiff" , {
628- child_process : {
629- exec : execStub ,
630- } ,
631- } ) ;
632-
633- try {
634- await oasDiff . checkOasDiffIsInstalled ( ) ;
635- expect . fail ( "Expected function to throw an error" ) ;
636- } catch ( error ) {
637- expect ( error . message ) . to . equal (
638- "oasdiff is not installed. Install oasdiff according to https://github.com/oasdiff/oasdiff#installation"
639- ) ;
640- }
641- } ) ;
642642} ) ;
0 commit comments