@@ -19,7 +19,7 @@ const mockConnections = [
19
19
favorite : {
20
20
name : 'turtles' ,
21
21
} ,
22
- savedConnectionType : 'favorite' ,
22
+ savedConnectionType : 'favorite' as const ,
23
23
} ,
24
24
{
25
25
id : 'oranges' ,
@@ -29,7 +29,7 @@ const mockConnections = [
29
29
favorite : {
30
30
name : 'peaches' ,
31
31
} ,
32
- savedConnectionType : 'favorite' ,
32
+ savedConnectionType : 'favorite' as const ,
33
33
} ,
34
34
] ;
35
35
@@ -242,7 +242,7 @@ describe('useConnections', function () {
242
242
describe ( `when multiple connections ${
243
243
multipleConnectionsEnabled ? 'enabled' : 'disabled'
244
244
} `, function ( ) {
245
- it ( 'should NOT update existing connection with new props when existing connection is successfull' , async function ( ) {
245
+ it ( 'should only update favorite info for existing connection with new props when existing connection is successfull' , async function ( ) {
246
246
const { result, connectionStorage } = renderHookWithConnections (
247
247
useConnections ,
248
248
{
@@ -256,13 +256,28 @@ describe('useConnections', function () {
256
256
257
257
await result . current . connect ( {
258
258
...mockConnections [ 0 ] ,
259
+ connectionOptions : {
260
+ ...mockConnections [ 0 ] . connectionOptions ,
261
+ connectionString : 'mongodb://foobar' ,
262
+ } ,
259
263
favorite : { name : 'foobar' } ,
260
264
} ) ;
261
265
262
- // Connection in the storage wasn't updated
263
- expect (
264
- await connectionStorage . load ( { id : mockConnections [ 0 ] . id } )
265
- ) . to . have . nested . property ( 'favorite.name' , 'turtles' ) ;
266
+ const storedConnection = await connectionStorage . load ( {
267
+ id : mockConnections [ 0 ] . id ,
268
+ } ) ;
269
+
270
+ // Connection string in the storage wasn't updated
271
+ expect ( storedConnection ) . to . have . nested . property (
272
+ 'connectionOptions.connectionString' ,
273
+ 'mongodb://turtle'
274
+ ) ;
275
+
276
+ // Connection favorite name was updated
277
+ expect ( storedConnection ) . to . have . nested . property (
278
+ 'favorite.name' ,
279
+ 'foobar'
280
+ ) ;
266
281
} ) ;
267
282
268
283
it ( 'should not update existing connection if connection failed' , async function ( ) {
@@ -366,7 +381,7 @@ describe('useConnections', function () {
366
381
favorite : {
367
382
name : 'peaches (50) peaches' ,
368
383
} ,
369
- savedConnectionType : 'favorite' ,
384
+ savedConnectionType : 'favorite' as const ,
370
385
} ;
371
386
372
387
await result . current . saveEditedConnection ( newConnection ) ;
@@ -387,7 +402,7 @@ describe('useConnections', function () {
387
402
388
403
const updatedConnection = {
389
404
...mockConnections [ 0 ] ,
390
- savedConnectionType : 'recent' ,
405
+ savedConnectionType : 'recent' as const ,
391
406
} ;
392
407
393
408
await result . current . saveEditedConnection ( updatedConnection ) ;
@@ -487,7 +502,7 @@ describe('useConnections', function () {
487
502
name : '' ,
488
503
color : 'color2' ,
489
504
} ,
490
- savedConnectionType : 'recent' ,
505
+ savedConnectionType : 'recent' as const ,
491
506
} ,
492
507
] ,
493
508
preferences : defaultPreferences ,
@@ -515,7 +530,7 @@ describe('useConnections', function () {
515
530
favorite : {
516
531
name : 'peaches (50) peaches' ,
517
532
} ,
518
- savedConnectionType : 'favorite' ,
533
+ savedConnectionType : 'favorite' as const ,
519
534
} ;
520
535
521
536
const { result, connectionsStore } = renderHookWithConnections (
0 commit comments