@@ -14,13 +14,14 @@ describe('EnterpriseConnectionAPI', () => {
1414 object : 'enterprise_connection' ,
1515 id : 'entconn_123' ,
1616 name : 'Clerk' ,
17- provider : 'saml_custom' ,
1817 domains : [ 'clerk.dev' ] ,
1918 organization_id : null ,
2019 created_at : 1672531200000 ,
2120 updated_at : 1672531200000 ,
2221 active : true ,
2322 sync_user_attributes : false ,
23+ allow_subdomains : false ,
24+ disable_additional_identifications : false ,
2425 } ;
2526
2627 describe ( 'createEnterpriseConnection' , ( ) => {
@@ -120,4 +121,79 @@ describe('EnterpriseConnectionAPI', () => {
120121 } ) ;
121122 } ) ;
122123 } ) ;
124+
125+ describe ( 'getEnterpriseConnectionList' , ( ) => {
126+ it ( 'successfully fetches enterprise connections with query params in snake_case' , async ( ) => {
127+ const mockListResponse = {
128+ data : [ mockEnterpriseConnectionResponse ] ,
129+ total_count : 1 ,
130+ } ;
131+
132+ let capturedRequestUrl : string | null = null ;
133+ server . use (
134+ http . get (
135+ 'https://api.clerk.test/v1/enterprise_connections' ,
136+ validateHeaders ( ( { request } ) => {
137+ capturedRequestUrl = request . url ;
138+ return HttpResponse . json ( mockListResponse ) ;
139+ } ) ,
140+ ) ,
141+ ) ;
142+
143+ const response = await apiClient . enterpriseConnections . getEnterpriseConnectionList ( {
144+ organizationId : 'org_123' ,
145+ active : true ,
146+ limit : 10 ,
147+ offset : 5 ,
148+ } ) ;
149+
150+ expect ( capturedRequestUrl ) . toBeTruthy ( ) ;
151+ const url = new URL ( capturedRequestUrl ! ) ;
152+ expect ( url . searchParams . get ( 'organization_id' ) ) . toBe ( 'org_123' ) ;
153+ expect ( url . searchParams . get ( 'active' ) ) . toBe ( 'true' ) ;
154+ expect ( url . searchParams . get ( 'limit' ) ) . toBe ( '10' ) ;
155+ expect ( url . searchParams . get ( 'offset' ) ) . toBe ( '5' ) ;
156+
157+ expect ( response . data ) . toHaveLength ( 1 ) ;
158+ expect ( response . data [ 0 ] . id ) . toBe ( 'entconn_123' ) ;
159+ expect ( response . data [ 0 ] . name ) . toBe ( 'Clerk' ) ;
160+ expect ( response . data [ 0 ] . domains ) . toEqual ( [ 'clerk.dev' ] ) ;
161+ expect ( response . totalCount ) . toBe ( 1 ) ;
162+ } ) ;
163+ } ) ;
164+
165+ describe ( 'getEnterpriseConnection' , ( ) => {
166+ it ( 'successfully fetches a single enterprise connection' , async ( ) => {
167+ server . use (
168+ http . get (
169+ 'https://api.clerk.test/v1/enterprise_connections/entconn_123' ,
170+ validateHeaders ( ( ) => HttpResponse . json ( mockEnterpriseConnectionResponse ) ) ,
171+ ) ,
172+ ) ;
173+
174+ const response = await apiClient . enterpriseConnections . getEnterpriseConnection ( 'entconn_123' ) ;
175+
176+ expect ( response . id ) . toBe ( 'entconn_123' ) ;
177+ expect ( response . name ) . toBe ( 'Clerk' ) ;
178+ expect ( response . domains ) . toEqual ( [ 'clerk.dev' ] ) ;
179+ expect ( response . active ) . toBe ( true ) ;
180+ expect ( response . organizationId ) . toBeNull ( ) ;
181+ } ) ;
182+ } ) ;
183+
184+ describe ( 'deleteEnterpriseConnection' , ( ) => {
185+ it ( 'successfully deletes an enterprise connection' , async ( ) => {
186+ server . use (
187+ http . delete (
188+ 'https://api.clerk.test/v1/enterprise_connections/entconn_123' ,
189+ validateHeaders ( ( ) => HttpResponse . json ( mockEnterpriseConnectionResponse ) ) ,
190+ ) ,
191+ ) ;
192+
193+ const response = await apiClient . enterpriseConnections . deleteEnterpriseConnection ( 'entconn_123' ) ;
194+
195+ expect ( response . id ) . toBe ( 'entconn_123' ) ;
196+ expect ( response . name ) . toBe ( 'Clerk' ) ;
197+ } ) ;
198+ } ) ;
123199} ) ;
0 commit comments