@@ -23,6 +23,16 @@ const mockSingleGroupBody = {
2323 created : '2025-01-01T00:00:00.000Z' ,
2424} ;
2525
26+ const mockSinglePersonBody = {
27+ id : 'test-person-id' ,
28+ targetName : 'jdoe' ,
29+ firstName : 'John' ,
30+ lastName : 'Doe' ,
31+ recipientType : 'PERSON' ,
32+ status : 'ACTIVE' ,
33+ created : '2025-01-01T00:00:00.000Z' ,
34+ } ;
35+
2636const mockPaginatedGroupsBody = {
2737 count : 1 ,
2838 total : 1 ,
@@ -32,6 +42,15 @@ const mockPaginatedGroupsBody = {
3242 } ,
3343} ;
3444
45+ const mockPaginatedPeopleBody = {
46+ count : 1 ,
47+ total : 1 ,
48+ data : [ mockSinglePersonBody ] ,
49+ links : {
50+ self : '/api/xm/1/groups/test-group-id/supervisors?limit=100&offset=0' ,
51+ } ,
52+ } ;
53+
3554Deno . test ( 'GroupsEndpoint' , async ( t ) => {
3655 await t . step ( 'get() - List Groups' , async ( t ) => {
3756 await t . step ( 'makes GET request without parameters' , async ( ) => {
@@ -354,6 +373,85 @@ Deno.test('GroupsEndpoint', async (t) => {
354373 } ) ;
355374 } ) ;
356375
376+ await t . step ( 'getSupervisors() - Get Group Supervisors' , async ( t ) => {
377+ await t . step ( 'makes GET request with group ID' , async ( ) => {
378+ mockHttpClient . setReqRes ( [ {
379+ expectedRequest : {
380+ method : 'GET' ,
381+ url : 'https://test.xmatters.com/api/xm/1/groups/test-group-id/supervisors' ,
382+ headers : TestConstants . BASIC_AUTH_HEADERS ,
383+ } ,
384+ mockedResponse : {
385+ status : 200 ,
386+ headers : { 'content-type' : 'application/json' } ,
387+ body : mockPaginatedPeopleBody ,
388+ } ,
389+ } ] ) ;
390+ await groups . getSupervisors ( 'test-group-id' ) ;
391+ } ) ;
392+
393+ await t . step ( 'makes GET request with group targetName' , async ( ) => {
394+ mockHttpClient . setReqRes ( [ {
395+ expectedRequest : {
396+ method : 'GET' ,
397+ url : 'https://test.xmatters.com/api/xm/1/groups/Oracle Administrators/supervisors' ,
398+ headers : TestConstants . BASIC_AUTH_HEADERS ,
399+ } ,
400+ mockedResponse : {
401+ status : 200 ,
402+ headers : { 'content-type' : 'application/json' } ,
403+ body : mockPaginatedPeopleBody ,
404+ } ,
405+ } ] ) ;
406+ await groups . getSupervisors ( 'Oracle Administrators' ) ;
407+ } ) ;
408+
409+ await t . step ( 'makes GET request with custom headers' , async ( ) => {
410+ mockHttpClient . setReqRes ( [ {
411+ expectedRequest : {
412+ method : 'GET' ,
413+ url : 'https://test.xmatters.com/api/xm/1/groups/test-group-id/supervisors' ,
414+ headers : {
415+ ...TestConstants . BASIC_AUTH_HEADERS ,
416+ 'X-Custom-Header' : 'custom-value' ,
417+ } ,
418+ } ,
419+ mockedResponse : {
420+ status : 200 ,
421+ headers : { 'content-type' : 'application/json' } ,
422+ body : mockPaginatedPeopleBody ,
423+ } ,
424+ } ] ) ;
425+ await groups . getSupervisors ( 'test-group-id' , {
426+ headers : {
427+ 'X-Custom-Header' : 'custom-value' ,
428+ } ,
429+ } ) ;
430+ } ) ;
431+
432+ await t . step ( 'makes GET request with query parameters' , async ( ) => {
433+ mockHttpClient . setReqRes ( [ {
434+ expectedRequest : {
435+ method : 'GET' ,
436+ url :
437+ 'https://test.xmatters.com/api/xm/1/groups/test-group-id/supervisors?limit=5&offset=10' ,
438+ headers : TestConstants . BASIC_AUTH_HEADERS ,
439+ } ,
440+ mockedResponse : {
441+ status : 200 ,
442+ headers : { 'content-type' : 'application/json' } ,
443+ body : mockPaginatedPeopleBody ,
444+ } ,
445+ } ] ) ;
446+ await groups . getSupervisors ( 'test-group-id' , {
447+ query : {
448+ limit : 5 ,
449+ offset : 10 ,
450+ } ,
451+ } ) ;
452+ } ) ;
453+ } ) ;
454+
357455 await t . step ( 'delete() - Delete Group' , async ( t ) => {
358456 await t . step ( 'makes DELETE request with group ID' , async ( ) => {
359457 mockHttpClient . setReqRes ( [ {
0 commit comments