@@ -2,28 +2,35 @@ import { describe, expect, it } from '@jest/globals';
22import { generateOperationID } from '../../rulesets/functions/utils/operationIdGeneration' ;
33
44describe ( 'tools/spectral/ipa/utils/operationIdGeneration.js' , ( ) => {
5- it ( 'should singularize all nouns' , ( ) => {
6- expect ( generateOperationID ( " create" , " /groups/{groupId}/clusters" ) ) . toEqual ( " createGroupCluster" ) ;
7- expect ( generateOperationID ( " delete" , " /groups/{groupId}/clusters/{clusterName}" ) ) . toEqual ( " deleteGroupCluster" ) ;
8- expect ( generateOperationID ( " get" , " /groups/{groupId}/clusters/{clusterName}" ) ) . toEqual ( " getGroupCluster" ) ;
9- expect ( generateOperationID ( " update" , " /groups/{groupId}/clusters/{clusterName}" ) ) . toEqual ( " updateGroupCluster" ) ;
10- expect ( generateOperationID ( " pause" , " /groups/{groupId}/clusters/{clusterName}" ) ) . toEqual ( " pauseGroupCluster" ) ;
11- } )
5+ it ( 'should singularize all nouns' , ( ) => {
6+ expect ( generateOperationID ( ' create' , ' /groups/{groupId}/clusters' ) ) . toEqual ( ' createGroupCluster' ) ;
7+ expect ( generateOperationID ( ' delete' , ' /groups/{groupId}/clusters/{clusterName}' ) ) . toEqual ( ' deleteGroupCluster' ) ;
8+ expect ( generateOperationID ( ' get' , ' /groups/{groupId}/clusters/{clusterName}' ) ) . toEqual ( ' getGroupCluster' ) ;
9+ expect ( generateOperationID ( ' update' , ' /groups/{groupId}/clusters/{clusterName}' ) ) . toEqual ( ' updateGroupCluster' ) ;
10+ expect ( generateOperationID ( ' pause' , ' /groups/{groupId}/clusters/{clusterName}' ) ) . toEqual ( ' pauseGroupCluster' ) ;
11+ } ) ;
1212
13- it ( 'should leave the final noun as is' , ( ) => {
14- expect ( generateOperationID ( "list" , "/groups/{groupId}/clusters" ) ) . toEqual ( "listGroupClusters" ) ;
15- expect ( generateOperationID ( "get" , "/groups/{groupId}/settings" ) ) . toEqual ( "getGroupSettings" ) ;
16- expect ( generateOperationID ( "update" , "/groups/{groupId}/settings" ) ) . toEqual ( "updateGroupSettings" ) ;
17- expect ( generateOperationID ( "search" , "/groups/{groupId}/clusters" ) ) . toEqual ( "searchGroupClusters" ) ;
18- expect ( generateOperationID ( "get" , "/groups/{groupId}/clusters/{clusterName}/{clusterView}/{databaseName}/{collectionName}/collStats/measurements" ) ) . toEqual ( "getGroupClusterCollStatMeasurements" ) ;
19- expect ( generateOperationID ( "grant" , "/api/atlas/v2/groups/{groupId}/access" ) ) . toEqual ( "grantGroupAccess" ) ;
20- } )
13+ it ( 'should leave the final noun as is' , ( ) => {
14+ expect ( generateOperationID ( 'list' , '/groups/{groupId}/clusters' ) ) . toEqual ( 'listGroupClusters' ) ;
15+ expect ( generateOperationID ( 'get' , '/groups/{groupId}/settings' ) ) . toEqual ( 'getGroupSettings' ) ;
16+ expect ( generateOperationID ( 'update' , '/groups/{groupId}/settings' ) ) . toEqual ( 'updateGroupSettings' ) ;
17+ expect ( generateOperationID ( 'search' , '/groups/{groupId}/clusters' ) ) . toEqual ( 'searchGroupClusters' ) ;
18+ expect (
19+ generateOperationID (
20+ 'get' ,
21+ '/groups/{groupId}/clusters/{clusterName}/{clusterView}/{databaseName}/{collectionName}/collStats/measurements'
22+ )
23+ ) . toEqual ( 'getGroupClusterCollStatMeasurements' ) ;
24+ expect ( generateOperationID ( 'grant' , '/api/atlas/v2/groups/{groupId}/access' ) ) . toEqual ( 'grantGroupAccess' ) ;
25+ } ) ;
2126
22- it ( 'should split camelCase method names' , ( ) => {
23- expect ( generateOperationID ( " addNode" , " /groups/{groupId}/clusters/{clusterName}" ) ) . toEqual ( " addGroupClusterNode" ) ;
24- } )
27+ it ( 'should split camelCase method names' , ( ) => {
28+ expect ( generateOperationID ( ' addNode' , ' /groups/{groupId}/clusters/{clusterName}' ) ) . toEqual ( ' addGroupClusterNode' ) ;
29+ } ) ;
2530
26- it ( 'should accomodate legacy custom methods' , ( ) => {
27- expect ( generateOperationID ( "" , "/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/restartPrimaries" ) ) . toEqual ( "restartGroupClusterPrimaries" ) ;
28- } )
29- } )
31+ it ( 'should accomodate legacy custom methods' , ( ) => {
32+ expect ( generateOperationID ( '' , '/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/restartPrimaries' ) ) . toEqual (
33+ 'restartGroupClusterPrimaries'
34+ ) ;
35+ } ) ;
36+ } ) ;
0 commit comments