11'use strict' ;
2- var expect = require ( 'chai' ) . expect ;
2+
3+ const expect = require ( 'chai' ) . expect ;
4+ const MongoClient = require ( '../..' ) . MongoClient ;
35
46describe ( 'URI' , function ( ) {
57 /**
@@ -15,7 +17,6 @@ describe('URI', function() {
1517 // The actual test we wish to run
1618 test : function ( done ) {
1719 var self = this ;
18- var MongoClient = self . configuration . require . MongoClient ;
1920
2021 // Connect using the connection string
2122 MongoClient . connect (
@@ -57,7 +58,6 @@ describe('URI', function() {
5758 // The actual test we wish to run
5859 test : function ( done ) {
5960 var self = this ;
60- var MongoClient = self . configuration . require . MongoClient ;
6161
6262 // Connect using the connection string
6363 MongoClient . connect ( 'mongodb://localhost:27017/integration_tests?w=0' , function ( err , client ) {
@@ -89,8 +89,6 @@ describe('URI', function() {
8989
9090 // The actual test we wish to run
9191 test : function ( done ) {
92- var MongoClient = this . configuration . require . MongoClient ;
93-
9492 if ( process . platform !== 'win32' ) {
9593 MongoClient . connect ( 'mongodb://%2Ftmp%2Fmongodb-27017.sock?safe=false' , function (
9694 err ,
@@ -114,8 +112,6 @@ describe('URI', function() {
114112 // The actual test we wish to run
115113 test : function ( done ) {
116114 var self = this ;
117- var MongoClient = self . configuration . require . MongoClient ;
118-
119115 MongoClient . connect ( 'mongodb://127.0.0.1:27017/?fsync=true' , function ( err , client ) {
120116 var db = client . db ( self . configuration . db ) ;
121117 expect ( db . writeConcern . fsync ) . to . be . true ;
@@ -133,7 +129,6 @@ describe('URI', function() {
133129 // The actual test we wish to run
134130 test : function ( done ) {
135131 var self = this ;
136- var MongoClient = self . configuration . require . MongoClient ;
137132
138133 MongoClient . connect (
139134 'mongodb://localhost:27017/integration_tests' ,
@@ -164,4 +159,22 @@ describe('URI', function() {
164159 ) ;
165160 }
166161 } ) ;
162+
163+ it ( 'should correctly translate uri options using new parser' , {
164+ metadata : { requires : { topology : 'replicaset' } } ,
165+ test : function ( done ) {
166+ const config = this . configuration ;
167+ const uri = `mongodb://${ config . host } :${ config . port } /${ config . db } ?replicaSet=${
168+ config . replicasetName
169+ } `;
170+
171+ MongoClient . connect ( uri , { useNewUrlParser : true } , ( err , client ) => {
172+ if ( err ) console . dir ( err ) ;
173+ expect ( err ) . to . not . exist ;
174+ expect ( client ) . to . exist ;
175+ expect ( client . s . options . replicaSet ) . to . exist . and . equal ( config . replicasetName ) ;
176+ done ( ) ;
177+ } ) ;
178+ }
179+ } ) ;
167180} ) ;
0 commit comments