File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -181,6 +181,68 @@ describe('Management User', () => {
181181 response : httpResponse ,
182182 } ) ;
183183 } ) ;
184+
185+ it ( 'should send templateId via the options argument' , async ( ) => {
186+ const httpResponse = {
187+ ok : true ,
188+ json : ( ) => mockMgmtUserResponse ,
189+ clone : ( ) => ( {
190+ json : ( ) => Promise . resolve ( mockMgmtUserResponse ) ,
191+ } ) ,
192+ status : 200 ,
193+ } ;
194+ mockHttpClient . post . mockResolvedValue ( httpResponse ) ;
195+
196+ await management . user . create ( 'loginId' , {
197+ email : 'a@b.c' ,
198+ templateId : 'my-template-id' ,
199+ } ) ;
200+
201+ expect ( mockHttpClient . post ) . toHaveBeenCalledWith ( apiPaths . user . create , {
202+ loginId : 'loginId' ,
203+ email : 'a@b.c' ,
204+ templateId : 'my-template-id' ,
205+ } ) ;
206+ } ) ;
207+
208+ it ( 'should send templateId via the positional arguments overload' , async ( ) => {
209+ const httpResponse = {
210+ ok : true ,
211+ json : ( ) => mockMgmtUserResponse ,
212+ clone : ( ) => ( {
213+ json : ( ) => Promise . resolve ( mockMgmtUserResponse ) ,
214+ } ) ,
215+ status : 200 ,
216+ } ;
217+ mockHttpClient . post . mockResolvedValue ( httpResponse ) ;
218+
219+ await management . user . create (
220+ 'loginId' ,
221+ 'a@b.c' ,
222+ undefined ,
223+ undefined ,
224+ undefined ,
225+ undefined ,
226+ undefined ,
227+ undefined ,
228+ undefined ,
229+ undefined ,
230+ undefined ,
231+ undefined ,
232+ undefined ,
233+ undefined ,
234+ 'my-template-id' ,
235+ ) ;
236+
237+ expect ( mockHttpClient . post ) . toHaveBeenCalledWith (
238+ apiPaths . user . create ,
239+ expect . objectContaining ( {
240+ loginId : 'loginId' ,
241+ email : 'a@b.c' ,
242+ templateId : 'my-template-id' ,
243+ } ) ,
244+ ) ;
245+ } ) ;
184246 } ) ;
185247
186248 describe ( 'createTestUser' , ( ) => {
Original file line number Diff line number Diff line change @@ -77,7 +77,12 @@ type MultipleUsersResponse = {
7777
7878const withUser = ( httpClient : HttpClient ) => {
7979 /* Create User */
80- function create ( loginId : string , options ?: UserOptions ) : Promise < SdkResponse < UserResponse > > ;
80+ function create (
81+ loginId : string ,
82+ options ?: UserOptions & {
83+ templateId ?: string ;
84+ } ,
85+ ) : Promise < SdkResponse < UserResponse > > ;
8186 function create (
8287 loginId : string ,
8388 email ?: string ,
@@ -93,6 +98,7 @@ const withUser = (httpClient: HttpClient) => {
9398 middleName ?: string ,
9499 familyName ?: string ,
95100 additionalLoginIds ?: string [ ] ,
101+ templateId ?: string ,
96102 ) : Promise < SdkResponse < UserResponse > > ;
97103
98104 function create (
@@ -110,6 +116,7 @@ const withUser = (httpClient: HttpClient) => {
110116 middleName ?: string ,
111117 familyName ?: string ,
112118 additionalLoginIds ?: string [ ] ,
119+ templateId ?: string ,
113120 ) : Promise < SdkResponse < UserResponse > > {
114121 // We support both the old and new parameters forms of create user
115122 // 1. The new form - create(loginId, { email, phone, ... }})
@@ -131,6 +138,7 @@ const withUser = (httpClient: HttpClient) => {
131138 verifiedEmail,
132139 verifiedPhone,
133140 additionalLoginIds,
141+ templateId,
134142 }
135143 : {
136144 loginId,
You can’t perform that action at this time.
0 commit comments