diff --git a/test/functional/readpreference.test.js b/test/functional/readpreference.test.js index d03a9eab0f3..d49c080e132 100644 --- a/test/functional/readpreference.test.js +++ b/test/functional/readpreference.test.js @@ -730,13 +730,31 @@ describe('ReadPreference', function() { }); }); - it('should respect readPreference from uri', function(done) { - const configuration = this.configuration; - const client = configuration.newClient(`${configuration.url()}?readPreference=secondary`); - client.connect(err => { - expect(err).to.not.exist; + it( + 'should respect readPreference from uri', + withMonitoredClient('find', { queryOptions: { readPreference: 'secondary' } }, function( + client, + events, + done + ) { expect(client.readPreference.mode).to.equal('secondary'); - client.close(done); - }); - }); + client + .db('test') + .collection('test') + .findOne({ a: 1 }, (err, result) => { + expect(err).to.not.exist; + expect(result).to.exist; + expect(events) + .to.be.an('array') + .with.lengthOf(1); + expect(events[0]).to.containSubset({ + commandName: 'find', + command: { + $readPreference: { mode: 'secondary' } + } + }); + done(); + }); + }) + ); }); diff --git a/test/functional/write_concern.test.js b/test/functional/write_concern.test.js index 3eb9c49cc36..0f73d5396ab 100644 --- a/test/functional/write_concern.test.js +++ b/test/functional/write_concern.test.js @@ -21,15 +21,29 @@ describe('Write Concern', function() { generateTopologyTests(testSuites, testContext); }); - it('should respect writeConcern from uri', function(done) { - const configuration = this.configuration; - const client = configuration.newClient(`${configuration.url()}?w=0`); - client.connect(err => { - expect(err).to.not.exist; + it( + 'should respect writeConcern from uri', + withMonitoredClient('insert', { queryOptions: { w: 0 } }, function(client, events, done) { expect(client.writeConcern).to.eql({ w: 0 }); - client.close(done); - }); - }); + client + .db('test') + .collection('test') + .insertOne({ a: 1 }, (err, result) => { + expect(err).to.not.exist; + expect(result).to.exist; + expect(events) + .to.be.an('array') + .with.lengthOf(1); + expect(events[0]).to.containSubset({ + commandName: 'insert', + command: { + writeConcern: { w: 0 } + } + }); + done(); + }); + }) + ); // TODO: once `read-write-concern/connection-string` spec tests are implemented these can likely be removed describe('test journal connection string option', function() {