@@ -19,7 +19,7 @@ vi.mock('@junobuild/config-loader', async () => {
1919describe ( 'init' , ( ) => {
2020 const args : ConfigArgs = {
2121 params : { } ,
22- mode : 'development '
22+ mode : 'production '
2323 } ;
2424
2525 let spyJunoConfigExist : MockInstance ;
@@ -30,13 +30,16 @@ describe('init', () => {
3030
3131 spyJunoConfigExist = vi . spyOn ( configLoader , 'junoConfigExist' ) . mockResolvedValue ( true ) ;
3232 spyReadJunoConfig = vi . spyOn ( configLoader , 'readJunoConfig' ) . mockResolvedValue ( {
33- satellite : { ids : { development : 'mock-satellite-id' } } ,
33+ satellite : { ids : { production : 'mock-satellite-id' } } ,
3434 orbiter : { id : 'mock-orbiter-id' }
3535 } ) ;
3636 } ) ;
3737
38- it ( 'returns config' , async ( ) => {
39- const result = await initConfig ( args ) ;
38+ it ( 'returns config for development' , async ( ) => {
39+ const result = await initConfig ( {
40+ params : { } ,
41+ mode : 'development'
42+ } ) ;
4043
4144 expect ( result ) . toEqual ( {
4245 orbiterId : undefined ,
@@ -54,10 +57,7 @@ describe('init', () => {
5457 } ) ;
5558
5659 it ( 'returns config without container for production' , async ( ) => {
57- const result = await initConfig ( {
58- ...args ,
59- mode : 'production'
60- } ) ;
60+ const result = await initConfig ( args ) ;
6161
6262 expect ( result ) . toEqual ( {
6363 satelliteId : 'mock-satellite-id' ,
@@ -97,17 +97,34 @@ describe('init', () => {
9797 expect ( spyReadJunoConfig ) . not . toHaveBeenCalled ( ) ;
9898 } ) ;
9999
100- it ( 'throws if config does not exist' , async ( ) => {
100+ it ( 'throws if config does not exist and mode is production ' , async ( ) => {
101101 vi . spyOn ( configLoader , 'junoConfigExist' ) . mockResolvedValue ( false ) ;
102102
103103 await expect ( initConfig ( args ) ) . rejects . toThrow ( / N o J u n o c o n f i g u r a t i o n f o u n d / ) ;
104104 } ) ;
105105
106+ it ( 'throws if satelliteId is missing in config if container is set to false' , async ( ) => {
107+ vi . spyOn ( configLoader , 'readJunoConfig' ) . mockResolvedValueOnce ( {
108+ satellite : { }
109+ } as unknown as JunoConfig ) ;
110+
111+ await expect (
112+ initConfig ( {
113+ params : {
114+ container : false
115+ } ,
116+ mode : 'development'
117+ } )
118+ ) . rejects . toThrow ( / A s a t e l l i t e I D f o r d e v e l o p m e n t m u s t b e s e t / ) ;
119+ } ) ;
120+
106121 it ( 'throws if satelliteId is missing in config' , async ( ) => {
107122 vi . spyOn ( configLoader , 'readJunoConfig' ) . mockResolvedValueOnce ( {
108123 satellite : { }
109124 } as unknown as JunoConfig ) ;
110125
111- await expect ( initConfig ( args ) ) . rejects . toThrow ( / A s a t e l l i t e I D f o r d e v e l o p m e n t m u s t b e s e t / ) ;
126+ await expect ( initConfig ( args ) ) . rejects . toThrow (
127+ / Y o u r c o n f i g u r a t i o n i s i n v a l i d . A s a t e l l i t e I D f o r p r o d u c t i o n m u s t b e s e t i n y o u r c o n f i g u r a t i o n f i l e ./
128+ ) ;
112129 } ) ;
113130} ) ;
0 commit comments