1
1
'use strict' ;
2
- var expect = require ( 'chai' ) . expect ;
2
+
3
+ const expect = require ( 'chai' ) . expect ;
4
+ const MongoClient = require ( '../..' ) . MongoClient ;
3
5
4
6
describe ( 'URI' , function ( ) {
5
7
/**
@@ -15,7 +17,6 @@ describe('URI', function() {
15
17
// The actual test we wish to run
16
18
test : function ( done ) {
17
19
var self = this ;
18
- var MongoClient = self . configuration . require . MongoClient ;
19
20
20
21
// Connect using the connection string
21
22
MongoClient . connect (
@@ -57,7 +58,6 @@ describe('URI', function() {
57
58
// The actual test we wish to run
58
59
test : function ( done ) {
59
60
var self = this ;
60
- var MongoClient = self . configuration . require . MongoClient ;
61
61
62
62
// Connect using the connection string
63
63
MongoClient . connect ( 'mongodb://localhost:27017/integration_tests?w=0' , function ( err , client ) {
@@ -89,8 +89,6 @@ describe('URI', function() {
89
89
90
90
// The actual test we wish to run
91
91
test : function ( done ) {
92
- var MongoClient = this . configuration . require . MongoClient ;
93
-
94
92
if ( process . platform !== 'win32' ) {
95
93
MongoClient . connect ( 'mongodb://%2Ftmp%2Fmongodb-27017.sock?safe=false' , function (
96
94
err ,
@@ -114,8 +112,6 @@ describe('URI', function() {
114
112
// The actual test we wish to run
115
113
test : function ( done ) {
116
114
var self = this ;
117
- var MongoClient = self . configuration . require . MongoClient ;
118
-
119
115
MongoClient . connect ( 'mongodb://127.0.0.1:27017/?fsync=true' , function ( err , client ) {
120
116
var db = client . db ( self . configuration . db ) ;
121
117
expect ( db . writeConcern . fsync ) . to . be . true ;
@@ -133,7 +129,6 @@ describe('URI', function() {
133
129
// The actual test we wish to run
134
130
test : function ( done ) {
135
131
var self = this ;
136
- var MongoClient = self . configuration . require . MongoClient ;
137
132
138
133
MongoClient . connect (
139
134
'mongodb://localhost:27017/integration_tests' ,
@@ -164,4 +159,22 @@ describe('URI', function() {
164
159
) ;
165
160
}
166
161
} ) ;
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
+ } ) ;
167
180
} ) ;
0 commit comments