Skip to content

Commit 77eef82

Browse files
committed
More tests
1 parent cb5898e commit 77eef82

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

src/mongo_client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export interface MongoURIOptions extends Pick<WriteConcernOptions, 'journal' | '
115115
SERVICE_NAME?: string;
116116
CANONICALIZE_HOST_NAME?: boolean;
117117
SERVICE_REALM?: string;
118+
[key: string]: any;
118119
};
119120
/** Set the Kerberos service name when connecting to Kerberized MongoDB instances. This value must match the service name set on MongoDB instances to which you are connecting. */
120121
gssapiServiceName?: string;
@@ -292,7 +293,7 @@ export class MongoClient extends EventEmitter implements OperationParent {
292293
this.originalUri = url;
293294
this.originalOptions = options;
294295

295-
// this.options = parseOptions(url, options);
296+
this.options = parseOptions(url, options);
296297

297298
// The internal state
298299
this.s = {

test/unit/mongo_client_options.test.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('MongoOptions', function () {
1919
});
2020
expect(options.directConnection).to.be.true;
2121
expect(options.domainsEnabled).to.be.false;
22-
expect(options.hosts).to.have.length(1);
22+
expect(options.hosts).has.length(1);
2323
expect(options.dbName).to.equal('test');
2424
expect(options.prototype).to.not.exist;
2525
});
@@ -28,8 +28,8 @@ describe('MongoOptions', function () {
2828
const options = parseOptions('mongodb://localhost:27017', { minSize: 2, poolSize: 4 });
2929
expect(options).to.not.have.property('minSize');
3030
expect(options).to.not.have.property('poolSize');
31-
expect(options).to.have.property('maxPoolSize', 4);
32-
expect(options).to.have.property('minPoolSize', 2);
31+
expect(options).has.property('maxPoolSize', 4);
32+
expect(options).has.property('minPoolSize', 2);
3333
});
3434

3535
it('tls renames', function () {
@@ -61,14 +61,14 @@ describe('MongoOptions', function () {
6161
expect(options).to.not.have.property('tlsCAFile');
6262
expect(options).to.not.have.property('sslCRL');
6363
expect(options).to.not.have.property('tlsCertificateKeyFilePassword');
64-
expect(options).to.have.property('ca', 'tlsCAFile');
65-
expect(options).to.have.property('crl', 'sslCRL');
66-
expect(options).to.have.property('cert', 'tlsCertificateFile');
67-
expect(options).to.have.property('key');
68-
expect(options.key).to.have.length(2);
69-
expect(options).to.have.property('passphrase', 'tlsCertificateKeyFilePassword');
70-
expect(options).to.have.property('rejectUnauthorized', false);
71-
expect(options).to.have.property('tls', true);
64+
expect(options).has.property('ca', 'tlsCAFile');
65+
expect(options).has.property('crl', 'sslCRL');
66+
expect(options).has.property('cert', 'tlsCertificateFile');
67+
expect(options).has.property('key');
68+
expect(options.key).has.length(2);
69+
expect(options).has.property('passphrase', 'tlsCertificateKeyFilePassword');
70+
expect(options).has.property('rejectUnauthorized', false);
71+
expect(options).has.property('tls', true);
7272
});
7373

7474
const ALL_OPTIONS = {
@@ -165,10 +165,10 @@ describe('MongoOptions', function () {
165165
const options = parseOptions('mongodb://localhost:27017/', ALL_OPTIONS);
166166

167167
// Check consolidated options
168-
expect(options).to.have.property('writeConcern');
169-
expect(options.writeConcern).to.have.property('w', 2);
170-
expect(options.writeConcern).to.have.property('fsync', true);
171-
expect(options.writeConcern).to.have.property('j', true);
168+
expect(options).has.property('writeConcern');
169+
expect(options.writeConcern).has.property('w', 2);
170+
expect(options.writeConcern).to.not.have.property('fsync');
171+
expect(options.writeConcern).has.property('j', true);
172172
});
173173

174174
const allURIOptions =
@@ -215,11 +215,15 @@ describe('MongoOptions', function () {
215215

216216
it('All URI options', function () {
217217
const options = parseOptions(allURIOptions);
218-
console.log(options);
218+
expect(options).has.property('zlibCompressionLevel', 2);
219+
220+
expect(options).has.property('writeConcern');
221+
expect(options.writeConcern).has.property('w', 'majority');
222+
expect(options.writeConcern).has.property('wtimeout', 2);
219223
});
220224

221225
it('srv', function () {
222226
const options = parseOptions('mongodb+srv://server.example.com/');
223-
expect(options).to.have.property('srv', true);
227+
expect(options).has.property('srv', true);
224228
});
225229
});

0 commit comments

Comments
 (0)