11//@ts -nocheck
22import { EndpointsApi } from '../../../api' ;
33import { Configuration } from '../../../configuration' ;
4- import { EndpointDirectionEnum , EndpointStatusEnum , EndpointTypeEnum } from '../../../models' ;
4+ import { CreateWebRtcConnectionRequest , EndpointDirectionEnum , EndpointStatusEnum , EndpointTypeEnum } from '../../../models' ;
55
66describe ( 'EndpointsApi' , ( ) => {
77 const config = new Configuration ( {
@@ -15,27 +15,20 @@ describe('EndpointsApi', () => {
1515 const endpointId = 'ep-123456' ;
1616
1717 describe ( 'createEndpoint' , ( ) => {
18- test ( 'should create endpoint and return full response shape ' , async ( ) => {
19- const { status , data } = await endpointsApi . createEndpoint ( accountId , {
18+ test ( 'should create endpoint' , async ( ) => {
19+ const createEndpointBody : CreateWebRtcConnectionRequest = {
2020 type : EndpointTypeEnum . Webrtc ,
2121 direction : EndpointDirectionEnum . Bidirectional
22- } ) ;
22+ } ;
23+
24+ const { status, data } = await endpointsApi . createEndpoint ( accountId , createEndpointBody ) ;
2325
2426 expect ( status ) . toEqual ( 201 ) ;
2527 expect ( data . links ) . toBeInstanceOf ( Array ) ;
2628 expect ( data . links . length ) . toBeGreaterThan ( 0 ) ;
27- expect ( data . links [ 0 ] ) . toContainKeys ( [ 'rel' , 'href' ] ) ;
2829 expect ( data . links [ 0 ] . rel ) . toBeString ( ) ;
2930 expect ( data . links [ 0 ] . href ) . toBeString ( ) ;
3031
31- expect ( data . data ) . toContainKeys ( [
32- 'endpointId' ,
33- 'type' ,
34- 'status' ,
35- 'creationTimestamp' ,
36- 'expirationTimestamp' ,
37- 'token'
38- ] ) ;
3932 expect ( data . data . endpointId ) . toBeString ( ) ;
4033 expect ( data . data . type ) . toBeOneOf ( Object . values ( EndpointTypeEnum ) ) ;
4134 expect ( data . data . status ) . toBeOneOf ( Object . values ( EndpointStatusEnum ) ) ;
@@ -49,30 +42,23 @@ describe('EndpointsApi', () => {
4942 } ) ;
5043
5144 describe ( 'listEndpoints' , ( ) => {
52- test ( 'should list endpoints and include links, page, data, and errors ' , async ( ) => {
45+ test ( 'should list endpoints' , async ( ) => {
5346 const { status, data } = await endpointsApi . listEndpoints ( accountId , EndpointTypeEnum . Webrtc , EndpointStatusEnum . Connected , undefined , 10 ) ;
5447
5548 expect ( status ) . toEqual ( 200 ) ;
5649 expect ( data . links ) . toBeInstanceOf ( Array ) ;
5750 expect ( data . links . length ) . toBeGreaterThan ( 0 ) ;
58- expect ( data . links [ 0 ] ) . toContainKeys ( [ 'rel' , 'href' ] ) ;
51+ expect ( data . links [ 0 ] . rel ) . toBeString ( ) ;
52+ expect ( data . links [ 0 ] . href ) . toBeString ( ) ;
5953 expect ( data . data ) . toBeInstanceOf ( Array ) ;
6054 expect ( data . page ) . toBeDefined ( ) ;
61- expect ( data . page ) . toContainKeys ( [ 'pageSize' , 'pageNumber' , 'totalPages' , 'totalElements' ] ) ;
6255 expect ( data . page . pageSize ) . toBeNumber ( ) ;
6356 expect ( data . page . pageNumber ) . toBeNumber ( ) ;
6457 expect ( data . page . totalPages ) . toBeNumber ( ) ;
6558 expect ( data . page . totalElements ) . toBeNumber ( ) ;
6659 expect ( data . errors ) . toBeInstanceOf ( Array ) ;
6760
6861 if ( data . data . length > 0 ) {
69- expect ( data . data [ 0 ] ) . toContainKeys ( [
70- 'endpointId' ,
71- 'type' ,
72- 'status' ,
73- 'creationTimestamp' ,
74- 'expirationTimestamp'
75- ] ) ;
7662 expect ( data . data [ 0 ] . endpointId ) . toBeString ( ) ;
7763 expect ( data . data [ 0 ] . type ) . toBeOneOf ( Object . values ( EndpointTypeEnum ) ) ;
7864 expect ( data . data [ 0 ] . status ) . toBeOneOf ( Object . values ( EndpointStatusEnum ) ) ;
@@ -83,21 +69,15 @@ describe('EndpointsApi', () => {
8369 } ) ;
8470
8571 describe ( 'getEndpoint' , ( ) => {
86- test ( 'should get endpoint and return full response shape ' , async ( ) => {
72+ test ( 'should get endpoint' , async ( ) => {
8773 const { status, data } = await endpointsApi . getEndpoint ( accountId , endpointId ) ;
8874
8975 expect ( status ) . toEqual ( 200 ) ;
9076 expect ( data . links ) . toBeInstanceOf ( Array ) ;
9177 expect ( data . links . length ) . toBeGreaterThan ( 0 ) ;
92- expect ( data . links [ 0 ] ) . toContainKeys ( [ 'rel' , 'href' ] ) ;
93-
94- expect ( data . data ) . toContainKeys ( [
95- 'endpointId' ,
96- 'type' ,
97- 'status' ,
98- 'creationTimestamp' ,
99- 'expirationTimestamp'
100- ] ) ;
78+ expect ( data . links [ 0 ] . rel ) . toBeString ( ) ;
79+ expect ( data . links [ 0 ] . href ) . toBeString ( ) ;
80+
10181 expect ( data . data . endpointId ) . toBeString ( ) ;
10282 expect ( data . data . type ) . toBeOneOf ( Object . values ( EndpointTypeEnum ) ) ;
10383 expect ( data . data . status ) . toBeOneOf ( Object . values ( EndpointStatusEnum ) ) ;
@@ -108,4 +88,12 @@ describe('EndpointsApi', () => {
10888 expect ( data . errors ) . toHaveLength ( 0 ) ;
10989 } ) ;
11090 } ) ;
91+
92+ describe ( 'deleteEndpoint' , ( ) => {
93+ test ( 'should delete endpoint' , async ( ) => {
94+ const { status } = await endpointsApi . deleteEndpoint ( accountId , endpointId ) ;
95+
96+ expect ( status ) . toEqual ( 204 ) ;
97+ } ) ;
98+ } ) ;
11199} ) ;
0 commit comments