@@ -6,32 +6,39 @@ import { diffsMatcher } from '../../../helper/matchers'
66const  COMPONENTS_SCHEMAS  =  [ 'components' ,  'schemas' ] 
77
88export  function  runResponseSiblingPropertiesSchema ( suiteId : string ,  commonPath : JsonPath ) : void   { 
9-   runTests ( suiteId ,  commonPath ,  true ) 
10- } 
11- 
12- export  function  runSiblingPropertiesSchema ( suiteId : string ,  commonPath : JsonPath ) : void   { 
13-   runTests ( suiteId ,  commonPath ,  false ) 
14- } 
9+   runTests ( suiteId ,  commonPath ) 
1510
16- function  runTests ( suiteId : string ,  commonPath : JsonPath ,  isResponse : boolean ) : void   { 
17-   test ( 'Add sibling description for ref' ,  async  ( )  =>  { 
18-     const  testId  =  'add-sibling-description-for-ref' 
11+   test ( 'Change referenced enum when sibling exists for ref' ,  async  ( )  =>  { 
12+     const  testId  =  'change-referenced-enum-when-sibling-exists-for-ref' 
1913    const  result  =  await  compareFiles ( suiteId ,  testId ) 
2014    expect ( result ) . toEqual ( diffsMatcher ( [ 
2115      expect . objectContaining ( { 
22-         action : DiffAction . replace , 
23-         afterDeclarationPaths : [ [ ...commonPath ,  'description' ] ] , 
24-         beforeDeclarationPaths : [ [ ...COMPONENTS_SCHEMAS ,  'Pet' ,  'description' ] ] , 
25-         type : annotation , 
16+         action : DiffAction . add , 
17+         afterDeclarationPaths : [ 
18+           [ ...COMPONENTS_SCHEMAS ,  'Color' ,  'enum' ,  1 ] , 
19+           [ ...commonPath ,  'enum' ,  1 ] , 
20+         ] , 
21+         type : risky , 
2622      } ) , 
2723    ] ) ) 
2824  } ) 
2925
30-   test ( 'Change  sibling enum  for ref' ,  async  ( )  =>  { 
31-     const  testId  =  'change -sibling-enum -for-ref' 
26+   test ( 'Remove  sibling maxLength  for ref' ,  async  ( )  =>  { 
27+     const  testId  =  'remove -sibling-maxLength -for-ref' 
3228    const  result  =  await  compareFiles ( suiteId ,  testId ) 
33-     expect ( result . length ) . toEqual ( 0 ) 
29+     expect ( result ) . toEqual ( diffsMatcher ( [ 
30+       expect . objectContaining ( { 
31+         action : DiffAction . replace , 
32+         beforeDeclarationPaths : [ [ ...commonPath ,  'maxLength' ] ] , 
33+         afterDeclarationPaths : [ [ ...COMPONENTS_SCHEMAS ,  'Color' ,  'maxLength' ] ] , 
34+         type : breaking , 
35+       } ) , 
36+     ] ) ) 
3437  } ) 
38+ } 
39+ 
40+ export  function  runSiblingPropertiesSchema ( suiteId : string ,  commonPath : JsonPath ) : void   { 
41+   runTests ( suiteId ,  commonPath ) 
3542
3643  test ( 'Change referenced enum when sibling exists for ref' ,  async  ( )  =>  { 
3744    const  testId  =  'change-referenced-enum-when-sibling-exists-for-ref' 
@@ -43,7 +50,7 @@ function runTests(suiteId: string, commonPath: JsonPath, isResponse: boolean): v
4350          [ ...COMPONENTS_SCHEMAS ,  'Color' ,  'enum' ,  1 ] , 
4451          [ ...commonPath ,  'enum' ,  1 ] , 
4552        ] , 
46-         type : isResponse  ?  risky  :  nonBreaking , 
53+         type : nonBreaking , 
4754      } ) , 
4855    ] ) ) 
4956  } ) 
@@ -56,8 +63,29 @@ function runTests(suiteId: string, commonPath: JsonPath, isResponse: boolean): v
5663        action : DiffAction . replace , 
5764        beforeDeclarationPaths : [ [ ...commonPath ,  'maxLength' ] ] , 
5865        afterDeclarationPaths : [ [ ...COMPONENTS_SCHEMAS ,  'Color' ,  'maxLength' ] ] , 
59-         type : isResponse  ? breaking  : nonBreaking , 
66+         type : nonBreaking , 
67+       } ) , 
68+     ] ) ) 
69+   } ) 
70+ } 
71+ 
72+ function  runTests ( suiteId : string ,  commonPath : JsonPath ) : void   { 
73+   test ( 'Add sibling description for ref' ,  async  ( )  =>  { 
74+     const  testId  =  'add-sibling-description-for-ref' 
75+     const  result  =  await  compareFiles ( suiteId ,  testId ) 
76+     expect ( result ) . toEqual ( diffsMatcher ( [ 
77+       expect . objectContaining ( { 
78+         action : DiffAction . replace , 
79+         afterDeclarationPaths : [ [ ...commonPath ,  'description' ] ] , 
80+         beforeDeclarationPaths : [ [ ...COMPONENTS_SCHEMAS ,  'Pet' ,  'description' ] ] , 
81+         type : annotation , 
6082      } ) , 
6183    ] ) ) 
6284  } ) 
85+ 
86+   test ( 'Change sibling enum for ref' ,  async  ( )  =>  { 
87+     const  testId  =  'change-sibling-enum-for-ref' 
88+     const  result  =  await  compareFiles ( suiteId ,  testId ) 
89+     expect ( result . length ) . toEqual ( 0 ) 
90+   } ) 
6391} 
0 commit comments