Skip to content

Commit c70cf11

Browse files
committed
test(NODE-7205): migrate to typescript
1 parent 1702987 commit c70cf11

1 file changed

Lines changed: 30 additions & 31 deletions

File tree

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
'use strict';
1+
import { expect } from 'chai';
22

3-
const { setupDatabase, assert: test } = require(`../shared`);
4-
const { expect } = require('chai');
5-
const { MongoClient, MongoInvalidArgumentError, MongoServerError } = require('../../mongodb');
3+
import { type Db, MongoClient, MongoInvalidArgumentError, MongoServerError } from '../../mongodb';
4+
import { assert as test, setupDatabase } from '../shared';
65

76
describe('Db', function () {
87
before(function () {
98
return setupDatabase(this.configuration);
109
});
1110

1211
context('when given illegal db name', function () {
13-
let client;
14-
let db;
12+
let client: MongoClient;
13+
let db: Db;
1514

1615
beforeEach(function () {
1716
client = this.configuration.newClient();
@@ -59,10 +58,10 @@ describe('Db', function () {
5958
},
6059

6160
test: function (done) {
62-
var configuration = this.configuration;
63-
var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 });
61+
const configuration = this.configuration;
62+
const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 });
6463
client.connect(function (err, client) {
65-
var _db = client.db('nonexistingdb');
64+
const _db = client.db('nonexistingdb');
6665

6766
_db.dropDatabase(function (err, result) {
6867
expect(err).to.not.exist;
@@ -80,8 +79,8 @@ describe('Db', function () {
8079
},
8180

8281
test: function (done) {
83-
var configuration = this.configuration;
84-
var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 });
82+
const configuration = this.configuration;
83+
const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 });
8584
client.connect(err => {
8685
expect(err).to.not.exist;
8786

@@ -101,12 +100,12 @@ describe('Db', function () {
101100
},
102101

103102
test: function (done) {
104-
var configuration = this.configuration;
105-
var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 });
103+
const configuration = this.configuration;
104+
const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 });
106105
client.connect(function (err, client) {
107106
expect(err).to.not.exist;
108107

109-
var db1 = client.db('node972');
108+
const db1 = client.db('node972');
110109
db1.collection('node972.test').insertOne({ a: 1 }, function (err) {
111110
expect(err).to.not.exist;
112111

@@ -129,14 +128,14 @@ describe('Db', function () {
129128
},
130129

131130
test: function (done) {
132-
var configuration = this.configuration;
131+
const configuration = this.configuration;
133132

134-
var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 });
133+
const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 });
135134
client.connect(function (err, client) {
136135
expect(err).to.not.exist;
137136

138137
// Get a db we that does not have any collections
139-
var db1 = client.db('shouldCorrectlyUseCursorWithListCollectionsCommand');
138+
const db1 = client.db('shouldCorrectlyUseCursorWithListCollectionsCommand');
140139

141140
// Create a collection
142141
db1.collection('test').insertOne({ a: 1 }, function (err) {
@@ -147,7 +146,7 @@ describe('Db', function () {
147146
expect(err).to.not.exist;
148147

149148
// Get listCollections filtering out the name
150-
var cursor = db1.listCollections({ name: 'test1' });
149+
const cursor = db1.listCollections({ name: 'test1' });
151150
cursor.toArray(function (err, names) {
152151
expect(err).to.not.exist;
153152
test.equal(1, names.length);
@@ -166,14 +165,14 @@ describe('Db', function () {
166165
},
167166

168167
test: function (done) {
169-
var configuration = this.configuration;
168+
const configuration = this.configuration;
170169

171-
var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 });
170+
const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 });
172171
client.connect(function (err, client) {
173172
expect(err).to.not.exist;
174173

175174
// Get a db we that does not have any collections
176-
var db1 = client.db('shouldCorrectlyUseCursorWithListCollectionsCommandAndBatchSize');
175+
const db1 = client.db('shouldCorrectlyUseCursorWithListCollectionsCommandAndBatchSize');
177176

178177
// Create a collection
179178
db1.collection('test').insertOne({ a: 1 }, function (err) {
@@ -184,7 +183,7 @@ describe('Db', function () {
184183
expect(err).to.not.exist;
185184

186185
// Get listCollections filtering out the name
187-
var cursor = db1.listCollections({ name: 'test' }, { batchSize: 1 });
186+
const cursor = db1.listCollections({ name: 'test' }, { batchSize: 1 });
188187
cursor.toArray(function (err, names) {
189188
expect(err).to.not.exist;
190189
test.equal(1, names.length);
@@ -203,14 +202,14 @@ describe('Db', function () {
203202
},
204203

205204
test: function (done) {
206-
var configuration = this.configuration;
205+
const configuration = this.configuration;
207206

208-
var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 });
207+
const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 });
209208
client.connect(function (err, client) {
210209
expect(err).to.not.exist;
211210

212211
// Get a db we that does not have any collections
213-
var db1 = client.db('shouldCorrectlyListCollectionsWithDotsOnThem');
212+
const db1 = client.db('shouldCorrectlyListCollectionsWithDotsOnThem');
214213

215214
// Create a collection
216215
db1.collection('test.collection1').insertOne({ a: 1 }, function (err) {
@@ -221,13 +220,13 @@ describe('Db', function () {
221220
expect(err).to.not.exist;
222221

223222
// Get listCollections filtering out the name
224-
var cursor = db1.listCollections({ name: /test.collection/ });
223+
const cursor = db1.listCollections({ name: /test.collection/ });
225224
cursor.toArray(function (err, names) {
226225
expect(err).to.not.exist;
227226
test.equal(2, names.length);
228227

229228
// Get listCollections filtering out the name
230-
var cursor = db1.listCollections({ name: 'test.collection1' }, {});
229+
const cursor = db1.listCollections({ name: 'test.collection1' }, {});
231230
cursor.toArray(function (err, names) {
232231
expect(err).to.not.exist;
233232
test.equal(1, names.length);
@@ -250,14 +249,14 @@ describe('Db', function () {
250249
},
251250

252251
test: function (done) {
253-
var configuration = this.configuration;
252+
const configuration = this.configuration;
254253

255-
var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 });
254+
const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 });
256255
client.connect(function (err, client) {
257256
expect(err).to.not.exist;
258257

259258
// Get a db we that does not have any collections
260-
var db1 = client.db('shouldCorrectlyListCollectionsWithDotsOnThemFor28');
259+
const db1 = client.db('shouldCorrectlyListCollectionsWithDotsOnThemFor28');
261260

262261
// Create a collection
263262
db1.collection('test.collection1').insertOne({ a: 1 }, function (err) {
@@ -268,7 +267,7 @@ describe('Db', function () {
268267
expect(err).to.not.exist;
269268

270269
// Get listCollections filtering out the name
271-
var cursor = db1.listCollections({ name: /test.collection/ }, { batchSize: 1 });
270+
const cursor = db1.listCollections({ name: /test.collection/ }, { batchSize: 1 });
272271
cursor.toArray(function (err, names) {
273272
expect(err).to.not.exist;
274273
test.equal(2, names.length);

0 commit comments

Comments
 (0)