@@ -19,7 +19,7 @@ const mockConnections = [
1919 favorite : {
2020 name : 'turtles' ,
2121 } ,
22- savedConnectionType : 'favorite' ,
22+ savedConnectionType : 'favorite' as const ,
2323 } ,
2424 {
2525 id : 'oranges' ,
@@ -29,7 +29,7 @@ const mockConnections = [
2929 favorite : {
3030 name : 'peaches' ,
3131 } ,
32- savedConnectionType : 'favorite' ,
32+ savedConnectionType : 'favorite' as const ,
3333 } ,
3434] ;
3535
@@ -242,7 +242,7 @@ describe('useConnections', function () {
242242 describe ( `when multiple connections ${
243243 multipleConnectionsEnabled ? 'enabled' : 'disabled'
244244 } `, 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 ( ) {
246246 const { result, connectionStorage } = renderHookWithConnections (
247247 useConnections ,
248248 {
@@ -256,13 +256,28 @@ describe('useConnections', function () {
256256
257257 await result . current . connect ( {
258258 ...mockConnections [ 0 ] ,
259+ connectionOptions : {
260+ ...mockConnections [ 0 ] . connectionOptions ,
261+ connectionString : 'mongodb://foobar' ,
262+ } ,
259263 favorite : { name : 'foobar' } ,
260264 } ) ;
261265
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+ ) ;
266281 } ) ;
267282
268283 it ( 'should not update existing connection if connection failed' , async function ( ) {
@@ -366,7 +381,7 @@ describe('useConnections', function () {
366381 favorite : {
367382 name : 'peaches (50) peaches' ,
368383 } ,
369- savedConnectionType : 'favorite' ,
384+ savedConnectionType : 'favorite' as const ,
370385 } ;
371386
372387 await result . current . saveEditedConnection ( newConnection ) ;
@@ -387,7 +402,7 @@ describe('useConnections', function () {
387402
388403 const updatedConnection = {
389404 ...mockConnections [ 0 ] ,
390- savedConnectionType : 'recent' ,
405+ savedConnectionType : 'recent' as const ,
391406 } ;
392407
393408 await result . current . saveEditedConnection ( updatedConnection ) ;
@@ -487,7 +502,7 @@ describe('useConnections', function () {
487502 name : '' ,
488503 color : 'color2' ,
489504 } ,
490- savedConnectionType : 'recent' ,
505+ savedConnectionType : 'recent' as const ,
491506 } ,
492507 ] ,
493508 preferences : defaultPreferences ,
@@ -515,7 +530,7 @@ describe('useConnections', function () {
515530 favorite : {
516531 name : 'peaches (50) peaches' ,
517532 } ,
518- savedConnectionType : 'favorite' ,
533+ savedConnectionType : 'favorite' as const ,
519534 } ;
520535
521536 const { result, connectionsStore } = renderHookWithConnections (
0 commit comments