@@ -263,147 +263,6 @@ describe("Contentstack", () => {
263263 done ( ) ;
264264 } ) ;
265265
266- describe ( 'getHostforRegion integration in stack creation' , ( ) => {
267- it ( 'should use getHostforRegion to set default hostname for aws_na region' , ( ) => {
268- const getHostforRegionSpy = jest . spyOn ( utils , 'getHostforRegion' ) ;
269- const config = {
270- apiKey : "apiKey" ,
271- deliveryToken : "delivery" ,
272- environment : "env" ,
273- region : "aws_na" ,
274- } ;
275-
276- const stackInstance = createStackInstance ( config ) ;
277-
278- expect ( getHostforRegionSpy ) . toHaveBeenCalledWith ( "aws_na" , undefined ) ;
279- expect ( stackInstance ) . toBeInstanceOf ( Stack ) ;
280-
281- getHostforRegionSpy . mockRestore ( ) ;
282- } ) ;
283-
284- it ( 'should use getHostforRegion to set default hostname for eu region' , ( ) => {
285- const getHostforRegionSpy = jest . spyOn ( utils , 'getHostforRegion' ) ;
286- const config = {
287- apiKey : "apiKey" ,
288- deliveryToken : "delivery" ,
289- environment : "env" ,
290- region : "eu" ,
291- } ;
292-
293- const stackInstance = createStackInstance ( config ) ;
294-
295- expect ( getHostforRegionSpy ) . toHaveBeenCalledWith ( "eu" , undefined ) ;
296- expect ( stackInstance ) . toBeInstanceOf ( Stack ) ;
297-
298- getHostforRegionSpy . mockRestore ( ) ;
299- } ) ;
300-
301- it ( 'should use getHostforRegion with custom host when both region and host are provided' , ( ) => {
302- const getHostforRegionSpy = jest . spyOn ( utils , 'getHostforRegion' ) ;
303- const config = {
304- apiKey : "apiKey" ,
305- deliveryToken : "delivery" ,
306- environment : "env" ,
307- region : "eu" ,
308- host : CUSTOM_HOST ,
309- } ;
310-
311- const stackInstance = createStackInstance ( config ) ;
312-
313- expect ( getHostforRegionSpy ) . toHaveBeenCalledWith ( "eu" , CUSTOM_HOST ) ;
314- expect ( stackInstance ) . toBeInstanceOf ( Stack ) ;
315-
316- getHostforRegionSpy . mockRestore ( ) ;
317- } ) ;
318-
319- it ( 'should use getHostforRegion for azure-na region' , ( ) => {
320- const getHostforRegionSpy = jest . spyOn ( utils , 'getHostforRegion' ) ;
321- const config = {
322- apiKey : "apiKey" ,
323- deliveryToken : "delivery" ,
324- environment : "env" ,
325- region : "azure-na" ,
326- } ;
327-
328- const stackInstance = createStackInstance ( config ) ;
329-
330- expect ( getHostforRegionSpy ) . toHaveBeenCalledWith ( "azure-na" , undefined ) ;
331- expect ( stackInstance ) . toBeInstanceOf ( Stack ) ;
332-
333- getHostforRegionSpy . mockRestore ( ) ;
334- } ) ;
335-
336- it ( 'should use getHostforRegion for gcp-na region' , ( ) => {
337- const getHostforRegionSpy = jest . spyOn ( utils , 'getHostforRegion' ) ;
338- const config = {
339- apiKey : "apiKey" ,
340- deliveryToken : "delivery" ,
341- environment : "env" ,
342- region : "gcp-na" ,
343- } ;
344-
345- const stackInstance = createStackInstance ( config ) ;
346-
347- expect ( getHostforRegionSpy ) . toHaveBeenCalledWith ( "gcp-na" , undefined ) ;
348- expect ( stackInstance ) . toBeInstanceOf ( Stack ) ;
349-
350- getHostforRegionSpy . mockRestore ( ) ;
351- } ) ;
352-
353- it ( 'should use getHostforRegion for gcp-eu region' , ( ) => {
354- const getHostforRegionSpy = jest . spyOn ( utils , 'getHostforRegion' ) ;
355- const config = {
356- apiKey : "apiKey" ,
357- deliveryToken : "delivery" ,
358- environment : "env" ,
359- region : "gcp-eu" ,
360- } ;
361-
362- const stackInstance = createStackInstance ( config ) ;
363-
364- expect ( getHostforRegionSpy ) . toHaveBeenCalledWith ( "gcp-eu" , undefined ) ;
365- expect ( stackInstance ) . toBeInstanceOf ( Stack ) ;
366-
367- getHostforRegionSpy . mockRestore ( ) ;
368- } ) ;
369-
370- it ( 'should handle getHostforRegion error gracefully' , ( ) => {
371- const getHostforRegionSpy = jest . spyOn ( utils , 'getHostforRegion' ) . mockImplementation ( ( ) => {
372- throw new Error ( 'Unable to set host using the provided region. Please provide a valid region.' ) ;
373- } ) ;
374-
375- const config = {
376- apiKey : "apiKey" ,
377- deliveryToken : "delivery" ,
378- environment : "env" ,
379- region : "invalid_region" ,
380- } ;
381-
382- expect ( ( ) => createStackInstance ( config ) ) . toThrow (
383- 'Unable to set host using the provided region. Please provide a valid region.'
384- ) ;
385-
386- getHostforRegionSpy . mockRestore ( ) ;
387- } ) ;
388-
389- it ( 'should use getHostforRegion with undefined region when no region is provided' , ( ) => {
390- const getHostforRegionSpy = jest . spyOn ( utils , 'getHostforRegion' ) ;
391- const config = {
392- apiKey : "apiKey" ,
393- deliveryToken : "delivery" ,
394- environment : "env" ,
395- } ;
396-
397- const stackInstance = createStackInstance ( config ) ;
398-
399- // When no region is provided, the default parameter "aws_na" is used
400- expect ( getHostforRegionSpy ) . toHaveBeenCalledWith ( "aws_na" , undefined ) ;
401- expect ( stackInstance ) . toBeInstanceOf ( Stack ) ;
402-
403- getHostforRegionSpy . mockRestore ( ) ;
404- } ) ;
405- } ) ;
406-
407266 describe ( 'locale configuration' , ( ) => {
408267 it ( 'should set locale in params when locale is provided in config' , ( ) => {
409268 const config = {
0 commit comments