Skip to content

Commit 718ca1a

Browse files
committed
test(NODE-7203): migrate to typescript
1 parent 1702987 commit 718ca1a

4 files changed

Lines changed: 46 additions & 48 deletions

File tree

test/integration/node-specific/bson-options/bsonRegExp.test.js renamed to test/integration/node-specific/bson-options/bsonRegExp.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
'use strict';
1+
import { expect } from 'chai';
22

3-
const { expect } = require('chai');
4-
const { BSONRegExp } = require('../../../mongodb');
3+
import { BSONRegExp } from '../../../mongodb';
54

65
describe('BSONRegExp', () => {
76
describe('bsonRegExp option', () => {

test/integration/node-specific/bson-options/ignore_undefined.test.js renamed to test/integration/node-specific/bson-options/ignore_undefined.test.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
'use strict';
2-
const { expect } = require('chai');
3-
const { assert: test, setupDatabase } = require('../../shared');
4-
const { ObjectId } = require('../../../mongodb');
1+
import { expect } from 'chai';
2+
3+
import { type MongoClient, ObjectId } from '../../../mongodb';
4+
import { assert as test, setupDatabase } from '../../shared';
55

66
describe('Ignore Undefined', function () {
77
before(function () {
88
return setupDatabase(this.configuration);
99
});
1010

11-
let client;
11+
let client: MongoClient;
1212

1313
beforeEach(async function () {
1414
client = this.configuration.newClient();
@@ -22,15 +22,15 @@ describe('Ignore Undefined', function () {
2222
metadata: { requires: { topology: ['single'] } },
2323

2424
test: function (done) {
25-
var configuration = this.configuration;
26-
var client = configuration.newClient(configuration.writeConcernMax(), {
25+
const configuration = this.configuration;
26+
const client = configuration.newClient(configuration.writeConcernMax(), {
2727
maxPoolSize: 1,
2828
ignoreUndefined: true
2929
});
3030

3131
client.connect(function (err, client) {
32-
var db = client.db(configuration.db);
33-
var collection = db.collection('shouldCorrectlyIgnoreUndefinedValue');
32+
const db = client.db(configuration.db);
33+
const collection = db.collection('shouldCorrectlyIgnoreUndefinedValue');
3434

3535
// Ignore the undefined field
3636
collection.insert({ a: 1, b: undefined }, configuration.writeConcernMax(), function (err) {
@@ -53,7 +53,7 @@ describe('Ignore Undefined', function () {
5353
metadata: { requires: { topology: ['single'] } },
5454

5555
test: function (done) {
56-
var configuration = this.configuration;
56+
const configuration = this.configuration;
5757
const client = configuration.newClient(
5858
{},
5959
{
@@ -62,8 +62,8 @@ describe('Ignore Undefined', function () {
6262
);
6363

6464
client.connect(function (err, client) {
65-
var db = client.db(configuration.db);
66-
var collection = db.collection('shouldCorrectlyIgnoreUndefinedValue1');
65+
const db = client.db(configuration.db);
66+
const collection = db.collection('shouldCorrectlyIgnoreUndefinedValue1');
6767
collection.insert({ a: 1, b: undefined }, function (err) {
6868
expect(err).to.not.exist;
6969

@@ -100,16 +100,16 @@ describe('Ignore Undefined', function () {
100100
metadata: { requires: { topology: ['single'] } },
101101

102102
test: function (done) {
103-
var configuration = this.configuration;
104-
var client = configuration.newClient(configuration.writeConcernMax(), {
103+
const configuration = this.configuration;
104+
const client = configuration.newClient(configuration.writeConcernMax(), {
105105
maxPoolSize: 1,
106106
ignoreUndefined: true
107107
});
108108

109109
client.connect(function (err, client) {
110-
var db = client.db(configuration.db);
111-
var collection = db.collection('shouldCorrectlyIgnoreUndefinedValue2');
112-
var id = new ObjectId();
110+
const db = client.db(configuration.db);
111+
const collection = db.collection('shouldCorrectlyIgnoreUndefinedValue2');
112+
const id = new ObjectId();
113113

114114
collection.updateOne(
115115
{ _id: id, a: 1, b: undefined },
@@ -120,7 +120,7 @@ describe('Ignore Undefined', function () {
120120
collection.findOne({ _id: id }, function (err, item) {
121121
test.equal(1, item.a);
122122
test.ok(item.b === undefined);
123-
var id = new ObjectId();
123+
const id = new ObjectId();
124124

125125
collection.updateMany(
126126
{ _id: id, a: 1, b: undefined },
@@ -131,7 +131,7 @@ describe('Ignore Undefined', function () {
131131
collection.findOne({ _id: id }, function (err, item) {
132132
test.equal(1, item.a);
133133
test.ok(item.b === undefined);
134-
var id = new ObjectId();
134+
const id = new ObjectId();
135135

136136
collection.update(
137137
{ _id: id, a: 1, b: undefined },

test/integration/node-specific/bson-options/promote_buffers.test.js renamed to test/integration/node-specific/bson-options/promote_buffers.test.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
'use strict';
2-
const { expect } = require('chai');
1+
import { expect } from 'chai';
32

4-
const { assert: test, setupDatabase } = require('../../shared');
3+
import { assert as test, setupDatabase } from '../../shared';
54

65
describe('Promote Buffers', function () {
76
before(function () {
@@ -16,14 +15,14 @@ describe('Promote Buffers', function () {
1615
},
1716

1817
test: function (done) {
19-
var configuration = this.configuration;
20-
var client = configuration.newClient(configuration.writeConcernMax(), {
18+
const configuration = this.configuration;
19+
const client = configuration.newClient(configuration.writeConcernMax(), {
2120
maxPoolSize: 1,
2221
promoteBuffers: true
2322
});
2423

2524
client.connect(function (err, client) {
26-
var db = client.db(configuration.db);
25+
const db = client.db(configuration.db);
2726
db.collection('shouldCorrectlyHonorPromoteBuffer1').insert(
2827
{
2928
doc: Buffer.alloc(256)
@@ -51,11 +50,11 @@ describe('Promote Buffers', function () {
5150
},
5251

5352
test: function (done) {
54-
var configuration = this.configuration;
53+
const configuration = this.configuration;
5554

5655
const client = configuration.newClient({}, { promoteBuffers: true });
5756
client.connect(function (err, client) {
58-
var db = client.db(configuration.db);
57+
const db = client.db(configuration.db);
5958

6059
db.collection('shouldCorrectlyHonorPromoteBuffer2').insert(
6160
{
@@ -84,11 +83,11 @@ describe('Promote Buffers', function () {
8483
},
8584

8685
test: function (done) {
87-
var configuration = this.configuration;
86+
const configuration = this.configuration;
8887

8988
const client = configuration.newClient({}, { promoteBuffers: true });
9089
client.connect(function (err, client) {
91-
var db = client.db(configuration.db);
90+
const db = client.db(configuration.db);
9291

9392
db.collection('shouldCorrectlyHonorPromoteBuffer3').insert(
9493
{
@@ -119,11 +118,11 @@ describe('Promote Buffers', function () {
119118
},
120119

121120
test: function (done) {
122-
var configuration = this.configuration;
121+
const configuration = this.configuration;
123122

124123
const client = configuration.newClient();
125124
client.connect(function (err, client) {
126-
var db = client.db(configuration.db);
125+
const db = client.db(configuration.db);
127126
db.collection('shouldCorrectlyHonorPromoteBuffer4').insert(
128127
{
129128
doc: Buffer.alloc(256)
@@ -155,11 +154,11 @@ describe('Promote Buffers', function () {
155154
},
156155

157156
test: function (done) {
158-
var configuration = this.configuration;
157+
const configuration = this.configuration;
159158

160159
const client = configuration.newClient();
161160
client.connect(function (err, client) {
162-
var db = client.db(configuration.db);
161+
const db = client.db(configuration.db);
163162
db.collection('shouldCorrectlyHonorPromoteBuffer5').insert(
164163
{
165164
doc: Buffer.alloc(256)

test/integration/node-specific/bson-options/promote_values.test.js renamed to test/integration/node-specific/bson-options/promote_values.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
'use strict';
2-
const { expect } = require('chai');
3-
const { Long, Int32, Double } = require('../../../mongodb');
4-
const { assert: test, setupDatabase } = require('../../shared');
1+
import { expect } from 'chai';
2+
3+
import { Double, Int32, Long } from '../../../mongodb';
4+
import { assert as test, setupDatabase } from '../../shared';
55

66
describe('Promote Values', function () {
77
before(function () {
@@ -16,21 +16,21 @@ describe('Promote Values', function () {
1616
},
1717

1818
test: async function () {
19-
let configuration = this.configuration;
20-
let client = configuration.newClient(configuration.writeConcernMax(), {
19+
const configuration = this.configuration;
20+
const client = configuration.newClient(configuration.writeConcernMax(), {
2121
maxPoolSize: 1,
2222
promoteValues: false
2323
});
2424
await client.connect();
25-
let db = client.db(configuration.db);
25+
const db = client.db(configuration.db);
2626

2727
await db.collection('shouldCorrectlyHonorPromoteValues').insertOne({
2828
doc: Long.fromNumber(10),
2929
int: 10,
3030
double: 2.2222,
3131
array: [[Long.fromNumber(10)]]
3232
});
33-
let doc = await db.collection('shouldCorrectlyHonorPromoteValues').findOne();
33+
const doc = await db.collection('shouldCorrectlyHonorPromoteValues').findOne();
3434
expect(Long.fromNumber(10)).deep.equals(doc.doc);
3535
expect(new Int32(10)).deep.equals(doc.int);
3636
expect(new Double(2.2222)).deep.equals(doc.double);
@@ -47,7 +47,7 @@ describe('Promote Values', function () {
4747
},
4848

4949
test: async function () {
50-
var configuration = this.configuration;
50+
const configuration = this.configuration;
5151
const client = configuration.newClient({}, { promoteValues: false });
5252
await client.connect();
5353
const db = client.db(configuration.db);
@@ -166,10 +166,10 @@ describe('Promote Values', function () {
166166
},
167167

168168
test: function (done) {
169-
var configuration = this.configuration;
169+
const configuration = this.configuration;
170170
const client = configuration.newClient();
171171
client.connect(function (err, client) {
172-
var docs = new Array(150).fill(0).map(function (_, i) {
172+
const docs = new Array(150).fill(0).map(function (_, i) {
173173
return {
174174
_id: 'needle_' + i,
175175
is_even: i % 2,
@@ -179,7 +179,7 @@ describe('Promote Values', function () {
179179
};
180180
});
181181

182-
var db = client.db(configuration.db);
182+
const db = client.db(configuration.db);
183183

184184
db.collection('haystack').insertMany(docs, function (errInsert) {
185185
if (errInsert) throw errInsert;

0 commit comments

Comments
 (0)