@@ -663,3 +663,85 @@ describe("normalizeConfig — Snowflake private_key edge cases", () => {
663663 expect ( result . private_key_path ) . toBeUndefined ( )
664664 } )
665665} )
666+
667+ // ---------------------------------------------------------------------------
668+ // normalizeConfig — MongoDB aliases
669+ // ---------------------------------------------------------------------------
670+
671+ describe ( "normalizeConfig — MongoDB" , ( ) => {
672+ test ( "connectionString → connection_string" , ( ) => {
673+ const result = normalizeConfig ( {
674+ type : "mongodb" ,
675+ connectionString : "mongodb://localhost:27017/mydb" ,
676+ } )
677+ expect ( result . connection_string ) . toBe ( "mongodb://localhost:27017/mydb" )
678+ expect ( result . connectionString ) . toBeUndefined ( )
679+ } )
680+
681+ test ( "uri → connection_string" , ( ) => {
682+ const result = normalizeConfig ( {
683+ type : "mongodb" ,
684+ uri : "mongodb://localhost:27017/mydb" ,
685+ } )
686+ expect ( result . connection_string ) . toBe ( "mongodb://localhost:27017/mydb" )
687+ expect ( result . uri ) . toBeUndefined ( )
688+ } )
689+
690+ test ( "authSource → auth_source" , ( ) => {
691+ const result = normalizeConfig ( {
692+ type : "mongodb" ,
693+ authSource : "admin" ,
694+ } )
695+ expect ( result . auth_source ) . toBe ( "admin" )
696+ expect ( result . authSource ) . toBeUndefined ( )
697+ } )
698+
699+ test ( "replicaSet → replica_set" , ( ) => {
700+ const result = normalizeConfig ( {
701+ type : "mongodb" ,
702+ replicaSet : "rs0" ,
703+ } )
704+ expect ( result . replica_set ) . toBe ( "rs0" )
705+ expect ( result . replicaSet ) . toBeUndefined ( )
706+ } )
707+
708+ test ( "directConnection → direct_connection" , ( ) => {
709+ const result = normalizeConfig ( {
710+ type : "mongodb" ,
711+ directConnection : true ,
712+ } )
713+ expect ( result . direct_connection ) . toBe ( true )
714+ expect ( result . directConnection ) . toBeUndefined ( )
715+ } )
716+
717+ test ( "connectTimeoutMS → connect_timeout" , ( ) => {
718+ const result = normalizeConfig ( {
719+ type : "mongodb" ,
720+ connectTimeoutMS : 5000 ,
721+ } )
722+ expect ( result . connect_timeout ) . toBe ( 5000 )
723+ expect ( result . connectTimeoutMS ) . toBeUndefined ( )
724+ } )
725+
726+ test ( "'mongo' type alias routes to MongoDB aliases" , ( ) => {
727+ const result = normalizeConfig ( {
728+ type : "mongo" ,
729+ uri : "mongodb://localhost/test" ,
730+ } )
731+ expect ( result . connection_string ) . toBe ( "mongodb://localhost/test" )
732+ expect ( result . uri ) . toBeUndefined ( )
733+ } )
734+
735+ test ( "canonical mongodb config passes through unchanged" , ( ) => {
736+ const config = {
737+ type : "mongodb" ,
738+ connection_string : "mongodb://localhost:27017" ,
739+ user : "admin" ,
740+ password : "secret" ,
741+ database : "mydb" ,
742+ auth_source : "admin" ,
743+ replica_set : "rs0" ,
744+ }
745+ expect ( normalizeConfig ( config ) ) . toEqual ( config )
746+ } )
747+ } )
0 commit comments