Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson committed Mar 31, 2023
1 parent a675fab commit 0066417
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { expect } from 'chai';
import {
connect,
Connection,
ConnectionOptions,
LEGACY_HELLO_COMMAND,
makeClientMetadata,
MongoClient,
MongoServerError,
ns,
Expand Down Expand Up @@ -31,12 +33,13 @@ describe('Connection', function () {
it('should execute a command against a server', {
metadata: { requires: { apiVersion: false, topology: '!load-balanced' } },
test: function (done) {
const connectOptions = Object.assign(
{ connectionType: Connection },
this.configuration.options
);
const connectOptions: Partial<ConnectionOptions> = {
connectionType: Connection,
...this.configuration.options,
metadata: makeClientMetadata({ driverInfo: {} })
};

connect(connectOptions, (err, conn) => {
connect(connectOptions as any as ConnectionOptions, (err, conn) => {
expect(err).to.not.exist;
this.defer(_done => conn.destroy(_done));

Expand All @@ -53,12 +56,14 @@ describe('Connection', function () {
it('should emit command monitoring events', {
metadata: { requires: { apiVersion: false, topology: '!load-balanced' } },
test: function (done) {
const connectOptions = Object.assign(
{ connectionType: Connection, monitorCommands: true },
this.configuration.options
);

connect(connectOptions, (err, conn) => {
const connectOptions: Partial<ConnectionOptions> = {
connectionType: Connection,
monitorCommands: true,
...this.configuration.options,
metadata: makeClientMetadata({ driverInfo: {} })
};

connect(connectOptions as any as ConnectionOptions, (err, conn) => {
expect(err).to.not.exist;
this.defer(_done => conn.destroy(_done));

Expand Down
5 changes: 4 additions & 1 deletion test/integration/node-specific/topology.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
'use strict';
const { expect } = require('chai');
const { makeClientMetadata } = require('../../mongodb');

describe('Topology', function () {
it('should correctly track states of a topology', {
metadata: { requires: { apiVersion: false, topology: '!load-balanced' } }, // apiVersion not supported by newTopology()
test: function (done) {
const topology = this.configuration.newTopology();
const topology = this.configuration.newTopology({
metadata: makeClientMetadata({ driverInfo: {} })
});

const states = [];
topology.on('stateChanged', (_, newState) => states.push(newState));
Expand Down

0 comments on commit 0066417

Please sign in to comment.