Skip to content

Commit 898a1cf

Browse files
committed
fix code coverage issues in tests
1 parent a657ddc commit 898a1cf

File tree

4 files changed

+34
-25
lines changed

4 files changed

+34
-25
lines changed

test/docs/validation.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,9 @@ describe('validation docs', function() {
381381
err.errors['numWheels'].message;
382382
// acquit:ignore:start
383383
assert.equal(err.errors['numWheels'].name, 'CastError');
384-
assert.equal(err.errors['numWheels'].message,
385-
'Cast to Number failed for value "not a number" (type string) at path "numWheels"');
384+
assert.ok(err.errors['numWheels'].message.startsWith(
385+
'Cast to Number failed for value "not a number"')
386+
);
386387
// acquit:ignore:end
387388
});
388389

test/double.test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,10 @@ describe('Double', function() {
281281
assert.ok(err);
282282
assert.ok(err.errors['myDouble']);
283283
assert.equal(err.errors['myDouble'].name, 'CastError');
284-
assert.equal(
285-
err.errors['myDouble'].message,
286-
'Cast to Double failed for value "helloworld" (type string) at path "myDouble"'
284+
assert.ok(
285+
err.errors['myDouble'].message.startsWith(
286+
'Cast to Double failed for value "helloworld" (type string) at path "myDouble"'
287+
)
287288
);
288289
});
289290
});

test/int32.test.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,10 @@ describe('Int32', function() {
301301
assert.ok(err);
302302
assert.ok(err.errors['myInt']);
303303
assert.equal(err.errors['myInt'].name, 'CastError');
304-
assert.equal(
305-
err.errors['myInt'].message,
306-
'Cast to Int32 failed for value "-42.4" (type number) at path "myInt"'
304+
assert.ok(
305+
err.errors['myInt'].message.startsWith(
306+
'Cast to Int32 failed for value "-42.4" (type number) at path "myInt"'
307+
)
307308
);
308309
});
309310
});
@@ -319,9 +320,10 @@ describe('Int32', function() {
319320
assert.ok(err);
320321
assert.ok(err.errors['myInt']);
321322
assert.equal(err.errors['myInt'].name, 'CastError');
322-
assert.equal(
323-
err.errors['myInt'].message,
324-
'Cast to Int32 failed for value "helloworld" (type string) at path "myInt"'
323+
assert.ok(
324+
err.errors['myInt'].message.startsWith(
325+
'Cast to Int32 failed for value "helloworld" (type string) at path "myInt"'
326+
)
325327
);
326328
});
327329
});
@@ -337,9 +339,10 @@ describe('Int32', function() {
337339
assert.ok(err);
338340
assert.ok(err.errors['myInt']);
339341
assert.equal(err.errors['myInt'].name, 'CastError');
340-
assert.equal(
341-
err.errors['myInt'].message,
342-
'Cast to Int32 failed for value "1.2" (type string) at path "myInt"'
342+
assert.ok(
343+
err.errors['myInt'].message.startsWith(
344+
'Cast to Int32 failed for value "1.2" (type string) at path "myInt"'
345+
)
343346
);
344347
});
345348
});
@@ -355,9 +358,10 @@ describe('Int32', function() {
355358
assert.ok(err);
356359
assert.ok(err.errors['myInt']);
357360
assert.equal(err.errors['myInt'].name, 'CastError');
358-
assert.equal(
359-
err.errors['myInt'].message,
360-
'Cast to Int32 failed for value "NaN" (type number) at path "myInt"'
361+
assert.ok(
362+
err.errors['myInt'].message.startsWith(
363+
'Cast to Int32 failed for value "NaN" (type number) at path "myInt"'
364+
)
361365
);
362366
});
363367
});
@@ -373,9 +377,10 @@ describe('Int32', function() {
373377
assert.ok(err);
374378
assert.ok(err.errors['myInt']);
375379
assert.equal(err.errors['myInt'].name, 'CastError');
376-
assert.equal(
377-
err.errors['myInt'].message,
378-
'Cast to Int32 failed for value "2147483648" (type number) at path "myInt"'
380+
assert.ok(
381+
err.errors['myInt'].message.startsWith(
382+
'Cast to Int32 failed for value "2147483648" (type number) at path "myInt"'
383+
)
379384
);
380385
});
381386
});
@@ -391,9 +396,10 @@ describe('Int32', function() {
391396
assert.ok(err);
392397
assert.ok(err.errors['myInt']);
393398
assert.equal(err.errors['myInt'].name, 'CastError');
394-
assert.equal(
395-
err.errors['myInt'].message,
396-
'Cast to Int32 failed for value "-2147483649" (type number) at path "myInt"'
399+
assert.ok(
400+
err.errors['myInt'].message.startsWith(
401+
'Cast to Int32 failed for value "-2147483649" (type number) at path "myInt"'
402+
)
397403
);
398404
});
399405
});

test/model.findOneAndUpdate.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,8 +1354,9 @@ describe('model: findOneAndUpdate:', function() {
13541354
const update = { $push: { addresses: { street: 'not a num' } } };
13551355
const error = await Person.findOneAndUpdate({}, update).then(() => null, err => err);
13561356
assert.ok(error.message.indexOf('street') !== -1);
1357-
assert.equal(error.reason.message,
1358-
'Cast to Number failed for value "not a num" (type string) at path "street"');
1357+
assert.ok(error.reason.message.startsWith(
1358+
'Cast to Number failed for value "not a num" (type string) at path "street"')
1359+
);
13591360
});
13601361

13611362
it('projection option as alias for fields (gh-4315)', async function() {

0 commit comments

Comments
 (0)