@@ -263,8 +263,8 @@ describe('Prefix Groups test', () => {
263263 const result = await buildPrefixGroupChangelogPackage ( {
264264 packageId : 'prefix-groups/different-prefix-length' ,
265265 config : {
266- previousGroup : '/api/v10' ,
267- currentGroup : 'api/v1000/' ,
266+ previousGroup : '/api/v10/ ' ,
267+ currentGroup : '/ api/v1000/' ,
268268 } ,
269269 } )
270270
@@ -280,5 +280,37 @@ describe('Prefix Groups test', () => {
280280 ] ) )
281281 } )
282282
283+ describe ( 'Validation of incorrect group prefixes' , ( ) => {
284+ test ( 'should throw error for invalid currentGroup - missing ending slash' , async ( ) => {
285+ await expect ( buildPrefixGroupChangelogPackage ( {
286+ packageId : 'prefix-groups/different-prefix-length' ,
287+ config : {
288+ previousGroup : '/api/v10/' ,
289+ currentGroup : '/api/v1000' ,
290+ } ,
291+ } ) ) . rejects . toThrow ( 'currentGroup must begin and end with a "/" character and contain at least one meaningful character, received: "/api/v1000"' )
292+ } )
293+
294+ test ( 'should throw error for invalid previousGroup - missing starting slash' , async ( ) => {
295+ await expect ( buildPrefixGroupChangelogPackage ( {
296+ packageId : 'prefix-groups/different-prefix-length' ,
297+ config : {
298+ previousGroup : 'api/v10/' ,
299+ currentGroup : '/api/v1000/' ,
300+ } ,
301+ } ) ) . rejects . toThrow ( 'previousGroup must begin and end with a "/" character and contain at least one meaningful character, received: "api/v10/"' )
302+ } )
303+
304+ test ( 'should throw error for group that is too short' , async ( ) => {
305+ await expect ( buildPrefixGroupChangelogPackage ( {
306+ packageId : 'prefix-groups/different-prefix-length' ,
307+ config : {
308+ previousGroup : '//' ,
309+ currentGroup : '/api/v1000/' ,
310+ } ,
311+ } ) ) . rejects . toThrow ( 'previousGroup must begin and end with a "/" character and contain at least one meaningful character, received: "//"' )
312+ } )
313+ } )
314+
283315 // todo add case when api/v1 in servers and api/v2 in some paths?
284316} )
0 commit comments