@@ -1083,6 +1083,95 @@ describe('Collection', () => {
10831083 } )
10841084 } )
10851085 } )
1086+
1087+ describe ( 'when retrieving by revisionId' , ( ) => {
1088+ test ( 'returns the specific revision when revisionId is provided' , async ( ) => {
1089+ nock ( / e x a m p l e - c m r / )
1090+ . defaultReplyHeaders ( {
1091+ 'CMR-Took' : 7 ,
1092+ 'CMR-Request-Id' : 'abcd-1234-efgh-5678'
1093+ } )
1094+ . get ( '/search/collections.umm_json?all_revisions=true&concept_id=C100000-EDSC' )
1095+ . reply ( 200 , {
1096+ items : [ {
1097+ meta : {
1098+ 'concept-id' : 'C100000-EDSC' ,
1099+ 'revision-id' : 2
1100+ } ,
1101+ umm : { }
1102+ } ]
1103+ } )
1104+
1105+ const response = await server . executeOperation ( {
1106+ variables : {
1107+ params : {
1108+ conceptId : 'C100000-EDSC' ,
1109+ revisionId : '2'
1110+ }
1111+ } ,
1112+ query : `
1113+ query GetCollection($params: CollectionInput!) {
1114+ collection(params: $params) {
1115+ conceptId
1116+ revisionId
1117+ }
1118+ }
1119+ `
1120+ } , {
1121+ contextValue
1122+ } )
1123+
1124+ const { data, errors } = response . body . singleResult
1125+
1126+ if ( errors ) {
1127+ console . error ( 'GraphQL errors:' , errors )
1128+ throw new Error ( 'GraphQL query resulted in errors' )
1129+ }
1130+
1131+ expect ( data ) . toEqual ( {
1132+ collection : {
1133+ conceptId : 'C100000-EDSC' ,
1134+ revisionId : '2'
1135+ }
1136+ } )
1137+ } )
1138+
1139+ test ( 'returns null when the specified revision does not exist' , async ( ) => {
1140+ nock ( / e x a m p l e - c m r / )
1141+ . defaultReplyHeaders ( {
1142+ 'CMR-Took' : 7 ,
1143+ 'CMR-Request-Id' : 'abcd-1234-efgh-5678'
1144+ } )
1145+ . get ( '/search/collections.umm_json?all_revisions=true&concept_id=C100000-EDSC' )
1146+ . reply ( 200 , {
1147+ items : [ ]
1148+ } )
1149+
1150+ const response = await server . executeOperation ( {
1151+ query : `query GetCollection($params: CollectionInput!) {
1152+ collection(params: $params) {
1153+ conceptId
1154+ revisionId
1155+ }
1156+ }` ,
1157+ variables : {
1158+ params : {
1159+ conceptId : 'C100000-EDSC' ,
1160+ revisionId : '2'
1161+ }
1162+ }
1163+ } , {
1164+ contextValue
1165+ } )
1166+
1167+ const { data, errors } = response . body . singleResult
1168+
1169+ expect ( errors ) . toBeUndefined ( )
1170+ expect ( data ) . toEqual ( {
1171+ collection : null
1172+ } )
1173+ } )
1174+ } )
10861175 } )
10871176 } )
10881177
0 commit comments