Skip to content

Commit

Permalink
fix: Check serializer argument type for empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
evaline-ju committed Oct 9, 2020
1 parent e7214f5 commit 14b116b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 3 additions & 7 deletions lib/nodejs/serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
'use strict';

const {type} = require('../utils');
const {
createInvalidArgumentTypeError,
createInvalidArgumentValueError
} = require('../errors');
const {createInvalidArgumentTypeError} = require('../errors');
// this is not named `mocha:parallel:serializer` because it's noisy and it's
// helpful to be able to write `DEBUG=mocha:parallel*` and get everything else.
const debug = require('debug')('mocha:serializer');
Expand Down Expand Up @@ -134,11 +131,10 @@ class SerializableEvent {
*/
constructor(eventName, originalValue, originalError) {
if (!eventName) {
throw createInvalidArgumentValueError(
throw createInvalidArgumentTypeError(
'Empty `eventName` string argument',
'eventName',
eventName,
'is empty'
'string'
);
}
/**
Expand Down
2 changes: 1 addition & 1 deletion test/node-unit/serializer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('serializer', function() {
describe('when called without `eventName`', function() {
it('should throw "invalid arg value" error', function() {
expect(() => new SerializableEvent(), 'to throw', {
code: 'ERR_MOCHA_INVALID_ARG_VALUE'
code: 'ERR_MOCHA_INVALID_ARG_TYPE'
});
});
});
Expand Down

0 comments on commit 14b116b

Please sign in to comment.