node/test/parallel/test-event-emitter-errors.js
Rich Trott d5d7a416c7
test: add trailing commas in event tests
As much as I would like to do this everywhere and then modify the lint
rule to enforce it, the churn would be too big. However if we're going
to have relatively frequent nits for this sort of thing (as we do), I'd
prefer we migrate a few files at a time to never actually getting around
to doing it.

Ref: https://github.com/nodejs/node/pull/45448#pullrequestreview-1179370442
PR-URL: https://github.com/nodejs/node/pull/45466
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-11-22 23:03:33 +00:00

38 lines
774 B
JavaScript

'use strict';
require('../common');
const assert = require('assert');
const EventEmitter = require('events');
const util = require('util');
const EE = new EventEmitter();
assert.throws(
() => EE.emit('error', 'Accepts a string'),
{
code: 'ERR_UNHANDLED_ERROR',
name: 'Error',
message: "Unhandled error. ('Accepts a string')",
}
);
assert.throws(
() => EE.emit('error', { message: 'Error!' }),
{
code: 'ERR_UNHANDLED_ERROR',
name: 'Error',
message: "Unhandled error. ({ message: 'Error!' })",
}
);
assert.throws(
() => EE.emit('error', {
message: 'Error!',
[util.inspect.custom]() { throw new Error(); },
}),
{
code: 'ERR_UNHANDLED_ERROR',
name: 'Error',
message: 'Unhandled error. ([object Object])',
}
);