@@ -36,15 +36,15 @@ vi.mock('@junobuild/config-loader', async () => {
36
36
describe ( 'config' , ( ) => {
37
37
describe ( 'useDockerContainer' , ( ) => {
38
38
it ( 'returns true if container is true and mode is development' , ( ) => {
39
- expect ( useDockerContainer ( { params : { container : true } , mode : MODE_DEVELOPMENT } ) ) . toBe ( true ) ;
39
+ expect ( useDockerContainer ( { params : { container : true } , mode : MODE_DEVELOPMENT } ) ) . toBeTruthy ( ) ;
40
40
} ) ;
41
41
42
42
it ( 'returns false if container is false' , ( ) => {
43
- expect ( useDockerContainer ( { params : { container : false } , mode : MODE_DEVELOPMENT } ) ) . toBe ( false ) ;
43
+ expect ( useDockerContainer ( { params : { container : false } , mode : MODE_DEVELOPMENT } ) ) . toBeFalsy ( ) ;
44
44
} ) ;
45
45
46
46
it ( 'returns false in production mode' , ( ) => {
47
- expect ( useDockerContainer ( { params : { container : true } , mode : 'production' } ) ) . toBe ( false ) ;
47
+ expect ( useDockerContainer ( { params : { container : true } , mode : 'production' } ) ) . toBeFalsy ( ) ;
48
48
} ) ;
49
49
50
50
it ( 'returns true if container has matching mode in modes[]' , ( ) => {
@@ -57,7 +57,7 @@ describe('config', () => {
57
57
} ,
58
58
mode : MODE_DEVELOPMENT
59
59
} )
60
- ) . toBe ( true ) ;
60
+ ) . toBeTruthy ( ) ;
61
61
} ) ;
62
62
63
63
it ( 'returns false if container has non-matching mode in modes[]' , ( ) => {
@@ -70,7 +70,7 @@ describe('config', () => {
70
70
} ,
71
71
mode : 'production'
72
72
} )
73
- ) . toBe ( false ) ;
73
+ ) . toBeFalsy ( ) ;
74
74
} ) ;
75
75
76
76
it ( 'returns true if container has no modes[] (default to development)' , ( ) => {
@@ -83,27 +83,27 @@ describe('config', () => {
83
83
} ,
84
84
mode : MODE_DEVELOPMENT
85
85
} )
86
- ) . toBe ( true ) ;
86
+ ) . toBeTruthy ( ) ;
87
87
} ) ;
88
88
89
89
it ( 'returns true if container is undefined and mode is development' , ( ) => {
90
- expect ( useDockerContainer ( { params : { } , mode : MODE_DEVELOPMENT } ) ) . toBe ( true ) ;
90
+ expect ( useDockerContainer ( { params : { } , mode : MODE_DEVELOPMENT } ) ) . toBeTruthy ( ) ;
91
91
} ) ;
92
92
93
93
it ( 'returns false if container is undefined and mode is production' , ( ) => {
94
- expect ( useDockerContainer ( { params : { } , mode : 'production' } ) ) . toBe ( false ) ;
94
+ expect ( useDockerContainer ( { params : { } , mode : 'production' } ) ) . toBeFalsy ( ) ;
95
95
} ) ;
96
96
97
97
it ( 'returns true if params is undefined and mode is development' , ( ) => {
98
- expect ( useDockerContainer ( { params : undefined , mode : MODE_DEVELOPMENT } ) ) . toBe ( true ) ;
98
+ expect ( useDockerContainer ( { params : undefined , mode : MODE_DEVELOPMENT } ) ) . toBeTruthy ( ) ;
99
99
} ) ;
100
100
101
101
it ( 'returns false if params is undefined and mode is production' , ( ) => {
102
- expect ( useDockerContainer ( { params : undefined , mode : 'production' } ) ) . toBe ( false ) ;
102
+ expect ( useDockerContainer ( { params : undefined , mode : 'production' } ) ) . toBeFalsy ( ) ;
103
103
} ) ;
104
104
105
105
it ( 'returns true if container is an empty object and mode is development' , ( ) => {
106
- expect ( useDockerContainer ( { params : { container : { } } , mode : MODE_DEVELOPMENT } ) ) . toBe ( true ) ;
106
+ expect ( useDockerContainer ( { params : { container : { } } , mode : MODE_DEVELOPMENT } ) ) . toBeTruthy ( ) ;
107
107
} ) ;
108
108
109
109
it ( 'returns false if container has empty modes[]' , ( ) => {
@@ -116,7 +116,7 @@ describe('config', () => {
116
116
} ,
117
117
mode : MODE_DEVELOPMENT
118
118
} )
119
- ) . toBe ( false ) ;
119
+ ) . toBeFalsy ( ) ;
120
120
} ) ;
121
121
} ) ;
122
122
@@ -125,11 +125,12 @@ describe('config', () => {
125
125
vi . clearAllMocks ( ) ;
126
126
} ) ;
127
127
128
- describe ( MODE_DEVELOPMENT , ( ) => {
128
+ describe ( ` ${ MODE_DEVELOPMENT } ` , ( ) => {
129
129
it ( 'returns docker satellite ID in dev mode with container true and no config file' , async ( ) => {
130
130
vi . spyOn ( configLoader , 'junoConfigExist' ) . mockResolvedValue ( false ) ;
131
131
132
132
const id = await satelliteId ( { params : { container : true } , mode : MODE_DEVELOPMENT } ) ;
133
+
133
134
expect ( id ) . toBe ( DOCKER_SATELLITE_ID ) ;
134
135
} ) ;
135
136
@@ -141,6 +142,7 @@ describe('config', () => {
141
142
} ) ;
142
143
143
144
const id = await satelliteId ( { params : { container : true } , mode : MODE_DEVELOPMENT } ) ;
145
+
144
146
expect ( id ) . toBe ( 'dev-custom-id' ) ;
145
147
} ) ;
146
148
@@ -152,6 +154,7 @@ describe('config', () => {
152
154
} ) ;
153
155
154
156
const id = await satelliteId ( { params : { container : true } , mode : MODE_DEVELOPMENT } ) ;
157
+
155
158
expect ( id ) . toBe ( DOCKER_SATELLITE_ID ) ;
156
159
} ) ;
157
160
@@ -163,6 +166,7 @@ describe('config', () => {
163
166
} ) ;
164
167
165
168
const id = await satelliteId ( { params : { container : true } , mode : MODE_DEVELOPMENT } ) ;
169
+
166
170
expect ( id ) . toBe ( DOCKER_SATELLITE_ID ) ;
167
171
} ) ;
168
172
} ) ;
@@ -176,6 +180,7 @@ describe('config', () => {
176
180
} ) ;
177
181
178
182
const id = await satelliteId ( { params : { container : false } , mode : 'production' } ) ;
183
+
179
184
expect ( id ) . toBe ( 'prod-sat-id' ) ;
180
185
} ) ;
181
186
@@ -208,11 +213,12 @@ describe('config', () => {
208
213
vi . clearAllMocks ( ) ;
209
214
} ) ;
210
215
211
- describe ( MODE_DEVELOPMENT , ( ) => {
216
+ describe ( ` ${ MODE_DEVELOPMENT } ` , ( ) => {
212
217
it ( 'returns undefined in dev mode with container true and no config file' , async ( ) => {
213
218
vi . spyOn ( configLoader , 'junoConfigExist' ) . mockResolvedValue ( false ) ;
214
219
215
220
const id = await orbiterId ( { params : { container : true } , mode : MODE_DEVELOPMENT } ) ;
221
+
216
222
expect ( id ) . toBeUndefined ( ) ;
217
223
} ) ;
218
224
@@ -224,6 +230,7 @@ describe('config', () => {
224
230
} as unknown as JunoConfig ) ;
225
231
226
232
const id = await orbiterId ( { params : { container : true } , mode : MODE_DEVELOPMENT } ) ;
233
+
227
234
expect ( id ) . toBe ( 'orb-dev-id' ) ;
228
235
} ) ;
229
236
@@ -235,6 +242,7 @@ describe('config', () => {
235
242
} as unknown as JunoConfig ) ;
236
243
237
244
const id = await orbiterId ( { params : { container : true } , mode : MODE_DEVELOPMENT } ) ;
245
+
238
246
expect ( id ) . toBeUndefined ( ) ;
239
247
} ) ;
240
248
@@ -246,6 +254,7 @@ describe('config', () => {
246
254
} as unknown as JunoConfig ) ;
247
255
248
256
const id = await orbiterId ( { params : { container : true } , mode : MODE_DEVELOPMENT } ) ;
257
+
249
258
expect ( id ) . toBeUndefined ( ) ;
250
259
} ) ;
251
260
@@ -257,6 +266,7 @@ describe('config', () => {
257
266
} as unknown as JunoConfig ) ;
258
267
259
268
const id = await orbiterId ( { params : { container : true } , mode : MODE_DEVELOPMENT } ) ;
269
+
260
270
expect ( id ) . toBeUndefined ( ) ;
261
271
} ) ;
262
272
} ) ;
@@ -274,6 +284,7 @@ describe('config', () => {
274
284
} as unknown as JunoConfig ) ;
275
285
276
286
const id = await orbiterId ( { params : { container : false } , mode : 'production' } ) ;
287
+
277
288
expect ( id ) . toBe ( 'orb-prod-id' ) ;
278
289
} ) ;
279
290
@@ -285,6 +296,7 @@ describe('config', () => {
285
296
} as unknown as JunoConfig ) ;
286
297
287
298
const id = await orbiterId ( { params : { container : false } , mode : 'production' } ) ;
299
+
288
300
expect ( id ) . toBe ( 'orb-id' ) ;
289
301
} ) ;
290
302
@@ -296,6 +308,7 @@ describe('config', () => {
296
308
} as unknown as JunoConfig ) ;
297
309
298
310
const id = await orbiterId ( { params : { } , mode : 'production' } ) ;
311
+
299
312
expect ( id ) . toBe ( 'fallback-id' ) ;
300
313
} ) ;
301
314
@@ -304,6 +317,7 @@ describe('config', () => {
304
317
vi . spyOn ( configLoader , 'readJunoConfig' ) . mockResolvedValue ( { } as unknown as JunoConfig ) ;
305
318
306
319
const id = await orbiterId ( { params : { } , mode : 'production' } ) ;
320
+
307
321
expect ( id ) . toBeUndefined ( ) ;
308
322
} ) ;
309
323
@@ -314,6 +328,7 @@ describe('config', () => {
314
328
) ;
315
329
316
330
const id = await orbiterId ( { params : { } , mode : 'production' } ) ;
331
+
317
332
expect ( id ) . toBeUndefined ( ) ;
318
333
} ) ;
319
334
} ) ;
@@ -353,11 +368,13 @@ describe('config', () => {
353
368
354
369
it ( 'returns default URL if container is true' , ( ) => {
355
370
const url = container ( { params : { container : true } , mode : MODE_DEVELOPMENT } ) ;
371
+
356
372
expect ( url ) . toBe ( 'http://127.0.0.1:5987' ) ;
357
373
} ) ;
358
374
359
375
it ( 'returns undefined in production when container is true' , ( ) => {
360
376
const url = container ( { params : { container : true } , mode : 'production' } ) ;
377
+
361
378
expect ( url ) . toBeUndefined ( ) ;
362
379
} ) ;
363
380
@@ -370,6 +387,7 @@ describe('config', () => {
370
387
} ,
371
388
mode : MODE_DEVELOPMENT
372
389
} ) ;
390
+
373
391
expect ( url ) . toBe ( 'http://custom-container.local' ) ;
374
392
} ) ;
375
393
@@ -382,6 +400,7 @@ describe('config', () => {
382
400
} ,
383
401
mode : MODE_DEVELOPMENT
384
402
} ) ;
403
+
385
404
expect ( url ) . toBe ( 'http://127.0.0.1:5987' ) ;
386
405
} ) ;
387
406
@@ -392,6 +411,7 @@ describe('config', () => {
392
411
} ,
393
412
mode : MODE_DEVELOPMENT
394
413
} ) ;
414
+
395
415
expect ( url ) . toBeUndefined ( ) ;
396
416
} ) ;
397
417
} ) ;
@@ -403,11 +423,13 @@ describe('config', () => {
403
423
404
424
it ( 'throws if config does not exist' , async ( ) => {
405
425
vi . spyOn ( configLoader , 'junoConfigExist' ) . mockResolvedValue ( false ) ;
426
+
406
427
await expect ( assertJunoConfig ( ) ) . rejects . toThrow ( JunoPluginError ) ;
407
428
} ) ;
408
429
409
430
it ( 'resolves if config exists' , async ( ) => {
410
431
vi . spyOn ( configLoader , 'junoConfigExist' ) . mockResolvedValue ( true ) ;
432
+
411
433
await expect ( assertJunoConfig ( ) ) . resolves . toBeUndefined ( ) ;
412
434
} ) ;
413
435
} ) ;
0 commit comments