Skip to content

Commit d94439f

Browse files
chore: enforce consistent block spacing in mocha tests (#4048)
1 parent a8670a7 commit d94439f

File tree

73 files changed

+131
-16
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+131
-16
lines changed

.eslintrc.json

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"plugin:@typescript-eslint/eslint-recommended",
1919
"plugin:@typescript-eslint/recommended",
2020
"plugin:prettier/recommended"
21-
// "plugin:mocha/recommended"
2221
],
2322
"env": {
2423
"node": true,
@@ -27,21 +26,6 @@
2726
},
2827
"reportUnusedDisableDirectives": true,
2928
"rules": {
30-
"no-restricted-properties": [
31-
"error",
32-
{
33-
"object": "describe",
34-
"property": "only"
35-
},
36-
{
37-
"object": "it",
38-
"property": "only"
39-
},
40-
{
41-
"object": "context",
42-
"property": "only"
43-
}
44-
],
4529
"no-restricted-globals": [
4630
"error",
4731
{
@@ -115,6 +99,8 @@
11599
}
116100
],
117101
"mocha/no-async-describe": "error",
102+
"mocha/no-exclusive-tests": "error",
103+
"mocha/consistent-spacing-between-blocks": "error",
118104
"no-restricted-syntax": [
119105
"error",
120106
{

test/action/dependency.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ describe('package.json', function () {
132132

133133
describe('mongodb imports', () => {
134134
let imports: string[];
135+
135136
beforeEach(async function () {
136137
for (const key of Object.keys(require.cache)) delete require.cache[key];
137138
require('../../src');

test/integration/change-streams/change_streams.prose.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ describe('Change Stream prose tests', function () {
111111
await client.close();
112112
}
113113
});
114+
114115
afterEach(async () => await mock.cleanup());
115116

116117
// TODO(NODE-3884): Add tests 1-4, 6-8. (#5 is removed from spec)
@@ -590,6 +591,7 @@ describe('Change Stream prose tests', function () {
590591
expect(tokens[0]).to.deep.equal(successes[1].nextBatch[0]._id);
591592
});
592593
});
594+
593595
it('must return resumeAfter from the initial aggregate if the option was specified', function () {
594596
const manager = new MockServerManager(this.configuration, {
595597
aggregate: (function* () {
@@ -629,6 +631,7 @@ describe('Change Stream prose tests', function () {
629631
expect(token).to.deep.equal(resumeAfter);
630632
});
631633
});
634+
632635
it('must be empty if resumeAfter options was not specified', function () {
633636
const manager = new MockServerManager(this.configuration, {
634637
aggregate: (function* () {
@@ -762,6 +765,7 @@ describe('Change Stream prose tests', function () {
762765
expect(token).to.deep.equal(startAfter).and.to.not.deep.equal(resumeAfter);
763766
});
764767
});
768+
765769
it('must return resumeAfter from the initial aggregate if the option was specified', function () {
766770
const manager = new MockServerManager(this.configuration, {
767771
aggregate: (function* () {
@@ -797,6 +801,7 @@ describe('Change Stream prose tests', function () {
797801
expect(token).to.deep.equal(resumeAfter);
798802
});
799803
});
804+
800805
it('must be empty if neither the startAfter nor resumeAfter options were specified', function () {
801806
const manager = new MockServerManager(this.configuration, {
802807
aggregate: (function* () {

test/integration/client-side-encryption/client_side_encryption.prose.12.deadlock.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ const metadata = {
105105
};
106106
describe('Connection Pool Deadlock Prevention', function () {
107107
installNodeDNSWorkaroundHooks();
108+
108109
beforeEach(async function () {
109110
const url: string = this.configuration.url();
110111

@@ -153,6 +154,7 @@ describe('Connection Pool Deadlock Prevention', function () {
153154
});
154155

155156
const CASE1 = { maxPoolSize: 1, bypassAutoEncryption: false, useKeyVaultClient: false };
157+
156158
it(
157159
'Case 1',
158160
metadata,
@@ -177,6 +179,7 @@ describe('Connection Pool Deadlock Prevention', function () {
177179
);
178180

179181
const CASE2 = { maxPoolSize: 1, bypassAutoEncryption: false, useKeyVaultClient: true };
182+
180183
it(
181184
'Case 2',
182185
metadata,
@@ -204,6 +207,7 @@ describe('Connection Pool Deadlock Prevention', function () {
204207
);
205208

206209
const CASE3 = { maxPoolSize: 1, bypassAutoEncryption: true, useKeyVaultClient: false };
210+
207211
it(
208212
'Case 3',
209213
metadata,
@@ -222,6 +226,7 @@ describe('Connection Pool Deadlock Prevention', function () {
222226
);
223227

224228
const CASE4 = { maxPoolSize: 1, bypassAutoEncryption: true, useKeyVaultClient: true };
229+
225230
it(
226231
'Case 4',
227232
metadata,
@@ -243,6 +248,7 @@ describe('Connection Pool Deadlock Prevention', function () {
243248
);
244249

245250
const CASE5 = { maxPoolSize: 0, bypassAutoEncryption: false, useKeyVaultClient: false };
251+
246252
it(
247253
'Case 5',
248254
metadata,
@@ -270,6 +276,7 @@ describe('Connection Pool Deadlock Prevention', function () {
270276
);
271277

272278
const CASE6 = { maxPoolSize: 0, bypassAutoEncryption: false, useKeyVaultClient: true };
279+
273280
it(
274281
'Case 6',
275282
metadata,
@@ -297,6 +304,7 @@ describe('Connection Pool Deadlock Prevention', function () {
297304
);
298305

299306
const CASE7 = { maxPoolSize: 0, bypassAutoEncryption: true, useKeyVaultClient: false };
307+
300308
it(
301309
'Case 7',
302310
metadata,
@@ -315,6 +323,7 @@ describe('Connection Pool Deadlock Prevention', function () {
315323
);
316324

317325
const CASE8 = { maxPoolSize: 0, bypassAutoEncryption: true, useKeyVaultClient: true };
326+
318327
it(
319328
'Case 8',
320329
metadata,

test/integration/client-side-encryption/client_side_encryption.prose.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
565565
const limitsDoc = loadLimits('limits-doc.json');
566566

567567
let hasRunFirstTimeSetup = false;
568+
568569
beforeEach(async function () {
569570
if (hasRunFirstTimeSetup) {
570571
// Even though we have to use a beforeEach here
@@ -1274,6 +1275,7 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
12741275
describe('via loading shared library', function () {
12751276
let clientEncrypted;
12761277
let client;
1278+
12771279
beforeEach(function () {
12781280
const { cryptSharedLibPath } = getEncryptExtraOptions();
12791281
if (!cryptSharedLibPath) {

test/integration/client-side-encryption/client_side_encryption.spec.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ describe('Client Side Encryption (Legacy)', function () {
6969
);
7070

7171
installNodeDNSWorkaroundHooks();
72+
7273
after(() => testContext.teardown());
74+
7375
before(function () {
7476
return testContext.setup(this.configuration);
7577
});

test/integration/collection-management/collection.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { setupDatabase } from '../shared';
66

77
describe('Collection', function () {
88
let configuration;
9+
910
before(function () {
1011
configuration = this.configuration;
1112
return setupDatabase(configuration, ['listCollectionsDb', 'listCollectionsDb2', 'test_db']);
@@ -14,6 +15,7 @@ describe('Collection', function () {
1415
describe('standard collection tests', function () {
1516
let client: MongoClient;
1617
let db: Db;
18+
1719
beforeEach(function () {
1820
client = configuration.newClient(configuration.writeConcernMax(), {
1921
maxPoolSize: 1

test/integration/collection-management/view.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { type CollectionInfo, type Db, type MongoClient } from '../../mongodb';
55
describe('Views', function () {
66
let client: MongoClient;
77
let db: Db;
8+
89
beforeEach(async function () {
910
const configuration = this.configuration;
1011
client = this.configuration.newClient();

test/integration/command-logging-and-monitoring/command_monitoring.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ describe('Command Monitoring', function () {
607607

608608
describe('Internal state references', function () {
609609
let client;
610+
610611
beforeEach(function () {
611612
client = this.configuration.newClient(
612613
{ writeConcern: { w: 1 } },

test/integration/connection-monitoring-and-pooling/connection_pool.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { type ConnectionPoolCreatedEvent, type Db, type MongoClient } from '../.
77
describe('Connection Pool', function () {
88
let client: MongoClient;
99
let db: Db;
10+
1011
afterEach(async function () {
1112
if (client) {
1213
if (db) {
@@ -15,6 +16,7 @@ describe('Connection Pool', function () {
1516
await client.close();
1617
}
1718
});
19+
1820
describe('Events', function () {
1921
describe('ConnectionPoolCreatedEvent', function () {
2022
context('when no connection pool options are passed in', function () {

0 commit comments

Comments
 (0)