Skip to content

Commit 584fc9d

Browse files
Refactor error handling in model tests
1 parent 148a6a8 commit 584fc9d

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

test/model.test.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ describe('Model', function() {
370370
assert.equal(post.get('comments')[0].comments[0].isNew, true);
371371
post.invalidate('title'); // force error
372372

373-
await post.save().catch(() => { });
373+
await post.save().catch(() => {});
374374
assert.equal(post.isNew, true);
375375
assert.equal(post.get('comments')[0].isNew, true);
376376
assert.equal(post.get('comments')[0].comments[0].isNew, true);
@@ -2477,7 +2477,7 @@ describe('Model', function() {
24772477

24782478
const DefaultErr = db.model('Test', DefaultErrSchema);
24792479

2480-
new DefaultErr().save().catch(() => { });
2480+
new DefaultErr().save().catch(() => {});
24812481

24822482
await new Promise(resolve => {
24832483
DefaultErr.once('error', function(err) {
@@ -3041,7 +3041,7 @@ describe('Model', function() {
30413041
const Location = db.model('Test', LocationSchema);
30423042

30433043

3044-
await Location.collection.drop().catch(() => { });
3044+
await Location.collection.drop().catch(() => {});
30453045
await Location.init();
30463046

30473047
await Location.create({
@@ -3510,7 +3510,7 @@ describe('Model', function() {
35103510
listener = null;
35113511
// Change stream may still emit "MongoAPIError: ChangeStream is closed" because change stream
35123512
// may still poll after close.
3513-
changeStream.on('error', () => { });
3513+
changeStream.on('error', () => {});
35143514
changeStream.close();
35153515
changeStream = null;
35163516
});
@@ -3662,7 +3662,7 @@ describe('Model', function() {
36623662

36633663
// Change stream may still emit "MongoAPIError: ChangeStream is closed" because change stream
36643664
// may still poll after close.
3665-
changeStream.on('error', () => { });
3665+
changeStream.on('error', () => {});
36663666
await changeStream.close();
36673667
await db.close();
36683668
});
@@ -3680,7 +3680,7 @@ describe('Model', function() {
36803680

36813681
// Change stream may still emit "MongoAPIError: ChangeStream is closed" because change stream
36823682
// may still poll after close.
3683-
changeStream.on('error', () => { });
3683+
changeStream.on('error', () => {});
36843684

36853685
const close = changeStream.close();
36863686
await db.asPromise();
@@ -3706,7 +3706,7 @@ describe('Model', function() {
37063706

37073707
// Change stream may still emit "MongoAPIError: ChangeStream is closed" because change stream
37083708
// may still poll after close.
3709-
changeStream.on('error', () => { });
3709+
changeStream.on('error', () => {});
37103710

37113711
changeStream.close();
37123712
const closedData = await closed;
@@ -5571,7 +5571,7 @@ describe('Model', function() {
55715571
const Model = db.model('User', userSchema);
55725572

55735573

5574-
await Model.collection.drop().catch(() => { });
5574+
await Model.collection.drop().catch(() => {});
55755575
await Model.createCollection();
55765576
const collectionName = Model.collection.name;
55775577

@@ -5605,7 +5605,7 @@ describe('Model', function() {
56055605
const Test = db.model('Test', schema, 'Test');
56065606
await Test.init();
56075607

5608-
await Test.collection.drop().catch(() => { });
5608+
await Test.collection.drop().catch(() => {});
56095609
await Test.createCollection();
56105610

56115611
const collections = await Test.db.db.listCollections().toArray();
@@ -5614,7 +5614,7 @@ describe('Model', function() {
56145614
assert.equal(coll.type, 'timeseries');
56155615
assert.equal(coll.options.timeseries.timeField, 'timestamp');
56165616

5617-
await Test.collection.drop().catch(() => { });
5617+
await Test.collection.drop().catch(() => {});
56185618
});
56195619

56205620
it('createCollection() enforces expireAfterSeconds (gh-11229)', async function() {
@@ -5635,7 +5635,7 @@ describe('Model', function() {
56355635

56365636
const Test = db.model('TestGH11229Var1', schema);
56375637

5638-
await Test.collection.drop().catch(() => { });
5638+
await Test.collection.drop().catch(() => {});
56395639
await Test.createCollection({ expireAfterSeconds: 5 });
56405640

56415641
const collOptions = await Test.collection.options();
@@ -5663,7 +5663,7 @@ describe('Model', function() {
56635663

56645664
const Test = db.model('TestGH11229Var2', schema, 'TestGH11229Var2');
56655665

5666-
await Test.collection.drop().catch(() => { });
5666+
await Test.collection.drop().catch(() => {});
56675667
await Test.createCollection({ expires: '5 seconds' });
56685668

56695669
const collOptions = await Test.collection.options();
@@ -5691,7 +5691,7 @@ describe('Model', function() {
56915691

56925692
const Test = db.model('TestGH11229Var3', schema);
56935693

5694-
await Test.collection.drop().catch(() => { });
5694+
await Test.collection.drop().catch(() => {});
56955695
await Test.createCollection();
56965696

56975697
const collOptions = await Test.collection.options();
@@ -5719,7 +5719,7 @@ describe('Model', function() {
57195719

57205720
const Test = db.model('TestGH11229Var4', schema);
57215721

5722-
await Test.collection.drop().catch(() => { });
5722+
await Test.collection.drop().catch(() => {});
57235723
await Test.createCollection();
57245724

57255725
const collOptions = await Test.collection.options();
@@ -5747,7 +5747,7 @@ describe('Model', function() {
57475747
const Test = db.model('Test', schema, 'Test');
57485748
await Test.init();
57495749

5750-
await Test.collection.drop().catch(() => { });
5750+
await Test.collection.drop().catch(() => {});
57515751
await Test.createCollection();
57525752

57535753
const collections = await Test.db.db.listCollections().toArray();
@@ -5756,7 +5756,7 @@ describe('Model', function() {
57565756
assert.deepEqual(coll.options.clusteredIndex.key, { _id: 1 });
57575757
assert.equal(coll.options.clusteredIndex.name, 'clustered test');
57585758

5759-
await Test.collection.drop().catch(() => { });
5759+
await Test.collection.drop().catch(() => {});
57605760
});
57615761

57625762
it('mongodb actually removes expired documents (gh-11229)', async function() {
@@ -5778,7 +5778,7 @@ describe('Model', function() {
57785778

57795779
const Test = db.model('TestMongoDBExpireRemoval', schema);
57805780

5781-
await Test.collection.drop().catch(() => { });
5781+
await Test.collection.drop().catch(() => {});
57825782
await Test.createCollection({ expireAfterSeconds: 5 });
57835783

57845784
await Test.insertMany([
@@ -5876,7 +5876,7 @@ describe('Model', function() {
58765876
const Model = db.model('User', userSchema);
58775877

58785878

5879-
await Model.collection.drop().catch(() => { });
5879+
await Model.collection.drop().catch(() => {});
58805880

58815881
await Model.createCollection();
58825882
await Model.createCollection();
@@ -6558,7 +6558,7 @@ describe('Model', function() {
65586558
await User.bulkWrite([
65596559
{
65606560
updateOne: {
6561-
filter: {},
6561+
filter: { },
65626562
update: { friends: ['Sam'] },
65636563
upsert: true,
65646564
setDefaultsOnInsert: true
@@ -7327,7 +7327,7 @@ describe('Model', function() {
73277327
});
73287328

73297329
it('insertMany should throw an error if there were operations that failed validation, ' +
7330-
'but all operations that passed validation succeeded (gh-14572) (gh-13256)', async function() {
7330+
'but all operations that passed validation succeeded (gh-14572) (gh-13256)', async function() {
73317331
const userSchema = new Schema({
73327332
age: { type: Number }
73337333
});
@@ -8489,7 +8489,7 @@ describe('Model', function() {
84898489
decoratorSchema.loadClass(Decorator);
84908490

84918491
// Define discriminated class before model is compiled
8492-
class Deco1 extends Decorator { whoAmI() { return 'I am Test1'; } }
8492+
class Deco1 extends Decorator { whoAmI() { return 'I am Test1'; }}
84938493
const deco1Schema = new Schema({});
84948494
deco1Schema.loadClass(Deco1);
84958495
decoratorSchema.discriminator('Test1', deco1Schema);
@@ -8501,7 +8501,7 @@ describe('Model', function() {
85018501
const shopModel = db.model('Test', shopSchema);
85028502

85038503
// Define another discriminated class after the model is compiled
8504-
class Deco2 extends Decorator { whoAmI() { return 'I am Test2'; } }
8504+
class Deco2 extends Decorator { whoAmI() { return 'I am Test2'; }}
85058505
const deco2Schema = new Schema({});
85068506
deco2Schema.loadClass(Deco2);
85078507
decoratorSchema.discriminator('Test2', deco2Schema);
@@ -8628,7 +8628,7 @@ describe('Model', function() {
86288628
});
86298629

86308630
it('insertMany should throw an error if there were operations that failed validation, ' +
8631-
'but all operations that passed validation succeeded (gh-13256)', async function() {
8631+
'but all operations that passed validation succeeded (gh-13256)', async function() {
86328632
const userSchema = new Schema({
86338633
age: { type: Number }
86348634
});

0 commit comments

Comments
 (0)