@@ -80,6 +80,43 @@ describe('Management Tenant', () => {
8080 response : httpResponse ,
8181 } ) ;
8282 } ) ;
83+
84+ it ( 'should send the correct request with parent parameter' , async ( ) => {
85+ const httpResponse = {
86+ ok : true ,
87+ json : ( ) => mockTenantCreateResponse ,
88+ clone : ( ) => ( {
89+ json : ( ) => Promise . resolve ( mockTenantCreateResponse ) ,
90+ } ) ,
91+ status : 200 ,
92+ } ;
93+ mockHttpClient . post . mockResolvedValue ( httpResponse ) ;
94+
95+ const resp : SdkResponse < CreateTenantResponse > = await management . tenant . create (
96+ 'child-tenant' ,
97+ [ 'child.example.com' ] ,
98+ { type : 'department' } ,
99+ false ,
100+ false ,
101+ 'parent-tenant-id' ,
102+ ) ;
103+
104+ expect ( mockHttpClient . post ) . toHaveBeenCalledWith ( apiPaths . tenant . create , {
105+ name : 'child-tenant' ,
106+ selfProvisioningDomains : [ 'child.example.com' ] ,
107+ customAttributes : { type : 'department' } ,
108+ enforceSSO : false ,
109+ disabled : false ,
110+ parent : 'parent-tenant-id' ,
111+ } ) ;
112+
113+ expect ( resp ) . toEqual ( {
114+ code : 200 ,
115+ data : mockTenantCreateResponse ,
116+ ok : true ,
117+ response : httpResponse ,
118+ } ) ;
119+ } ) ;
83120 } ) ;
84121
85122 describe ( 'createWithId' , ( ) => {
@@ -119,6 +156,45 @@ describe('Management Tenant', () => {
119156 response : httpResponse ,
120157 } ) ;
121158 } ) ;
159+
160+ it ( 'should send the correct request with parent parameter' , async ( ) => {
161+ const httpResponse = {
162+ ok : true ,
163+ json : ( ) => { } ,
164+ clone : ( ) => ( {
165+ json : ( ) => Promise . resolve ( { } ) ,
166+ } ) ,
167+ status : 200 ,
168+ } ;
169+ mockHttpClient . post . mockResolvedValue ( httpResponse ) ;
170+
171+ const resp : SdkResponse < CreateTenantResponse > = await management . tenant . createWithId (
172+ 'custom-child-id' ,
173+ 'child-tenant' ,
174+ [ 'child.example.com' ] ,
175+ { type : 'department' } ,
176+ false ,
177+ false ,
178+ 'parent-tenant-id' ,
179+ ) ;
180+
181+ expect ( mockHttpClient . post ) . toHaveBeenCalledWith ( apiPaths . tenant . create , {
182+ id : 'custom-child-id' ,
183+ name : 'child-tenant' ,
184+ selfProvisioningDomains : [ 'child.example.com' ] ,
185+ customAttributes : { type : 'department' } ,
186+ enforceSSO : false ,
187+ disabled : false ,
188+ parent : 'parent-tenant-id' ,
189+ } ) ;
190+
191+ expect ( resp ) . toEqual ( {
192+ code : 200 ,
193+ data : { } ,
194+ ok : true ,
195+ response : httpResponse ,
196+ } ) ;
197+ } ) ;
122198 } ) ;
123199
124200 describe ( 'update' , ( ) => {
@@ -240,6 +316,76 @@ describe('Management Tenant', () => {
240316 } ) ;
241317 } ) ;
242318
319+ describe ( 'searchAll' , ( ) => {
320+ it ( 'should send the correct request and receive correct response' , async ( ) => {
321+ const httpResponse = {
322+ ok : true ,
323+ json : ( ) => mockAllTenantsResponse ,
324+ clone : ( ) => ( {
325+ json : ( ) => Promise . resolve ( mockAllTenantsResponse ) ,
326+ } ) ,
327+ status : 200 ,
328+ } ;
329+ mockHttpClient . post . mockResolvedValue ( httpResponse ) ;
330+
331+ const resp : SdkResponse < Tenant [ ] > = await management . tenant . searchAll (
332+ [ 't1' , 't2' ] ,
333+ [ 'name1' ] ,
334+ [ 'domain1.com' ] ,
335+ { customAttr : 'value' } ,
336+ ) ;
337+
338+ expect ( mockHttpClient . post ) . toHaveBeenCalledWith ( apiPaths . tenant . searchAll , {
339+ tenantIds : [ 't1' , 't2' ] ,
340+ tenantNames : [ 'name1' ] ,
341+ tenantSelfProvisioningDomains : [ 'domain1.com' ] ,
342+ customAttributes : { customAttr : 'value' } ,
343+ } ) ;
344+
345+ expect ( resp ) . toEqual ( {
346+ code : 200 ,
347+ data : mockTenants ,
348+ ok : true ,
349+ response : httpResponse ,
350+ } ) ;
351+ } ) ;
352+
353+ it ( 'should send the correct request with parentTenantId parameter' , async ( ) => {
354+ const httpResponse = {
355+ ok : true ,
356+ json : ( ) => mockAllTenantsResponse ,
357+ clone : ( ) => ( {
358+ json : ( ) => Promise . resolve ( mockAllTenantsResponse ) ,
359+ } ) ,
360+ status : 200 ,
361+ } ;
362+ mockHttpClient . post . mockResolvedValue ( httpResponse ) ;
363+
364+ const resp : SdkResponse < Tenant [ ] > = await management . tenant . searchAll (
365+ undefined ,
366+ undefined ,
367+ undefined ,
368+ undefined ,
369+ 'parent-tenant-id' ,
370+ ) ;
371+
372+ expect ( mockHttpClient . post ) . toHaveBeenCalledWith ( apiPaths . tenant . searchAll , {
373+ tenantIds : undefined ,
374+ tenantNames : undefined ,
375+ tenantSelfProvisioningDomains : undefined ,
376+ customAttributes : undefined ,
377+ parentTenantId : 'parent-tenant-id' ,
378+ } ) ;
379+
380+ expect ( resp ) . toEqual ( {
381+ code : 200 ,
382+ data : mockTenants ,
383+ ok : true ,
384+ response : httpResponse ,
385+ } ) ;
386+ } ) ;
387+ } ) ;
388+
243389 describe ( 'getSettings' , ( ) => {
244390 it ( 'should send the correct request and receive correct response' , async ( ) => {
245391 const httpResponse = {
0 commit comments