@@ -6,6 +6,11 @@ const { MongoClient } = require('mongodb');
6
6
const databaseURI =
7
7
'mongodb://localhost:27017/parseServerMongoAdapterTestDatabase' ;
8
8
9
+ const fakeClient = {
10
+ s : { options : { dbName : null } } ,
11
+ db : ( ) => null ,
12
+ } ;
13
+
9
14
// These tests are specific to the mongo storage adapter + mongo storage format
10
15
// and will eventually be moved into their own repo
11
16
describe_only_db ( 'mongo' ) ( 'MongoStorageAdapter' , ( ) => {
@@ -16,7 +21,7 @@ describe_only_db('mongo')('MongoStorageAdapter', () => {
16
21
} ) ;
17
22
18
23
it ( 'auto-escapes symbols in auth information' , ( ) => {
19
- spyOn ( MongoClient , 'connect' ) . and . returnValue ( Promise . resolve ( null ) ) ;
24
+ spyOn ( MongoClient , 'connect' ) . and . returnValue ( Promise . resolve ( fakeClient ) ) ;
20
25
new MongoStorageAdapter ( {
21
26
uri :
22
27
'mongodb://user!with@+ symbols:password!with@+ symbols@localhost:1234/parse' ,
@@ -28,7 +33,7 @@ describe_only_db('mongo')('MongoStorageAdapter', () => {
28
33
} ) ;
29
34
30
35
it ( "doesn't double escape already URI-encoded information" , ( ) => {
31
- spyOn ( MongoClient , 'connect' ) . and . returnValue ( Promise . resolve ( null ) ) ;
36
+ spyOn ( MongoClient , 'connect' ) . and . returnValue ( Promise . resolve ( fakeClient ) ) ;
32
37
new MongoStorageAdapter ( {
33
38
uri :
34
39
'mongodb://user!with%40%2B%20symbols:password!with%40%2B%20symbols@localhost:1234/parse' ,
@@ -41,7 +46,7 @@ describe_only_db('mongo')('MongoStorageAdapter', () => {
41
46
42
47
// https://github.com/parse-community/parse-server/pull/148#issuecomment-180407057
43
48
it ( 'preserves replica sets' , ( ) => {
44
- spyOn ( MongoClient , 'connect' ) . and . returnValue ( Promise . resolve ( null ) ) ;
49
+ spyOn ( MongoClient , 'connect' ) . and . returnValue ( Promise . resolve ( fakeClient ) ) ;
45
50
new MongoStorageAdapter ( {
46
51
uri :
47
52
'mongodb://test:testpass@ds056315-a0.mongolab.com:59325,ds059315-a1.mongolab.com:59315/testDBname?replicaSet=rs-ds059415' ,
0 commit comments