Skip to content

Commit c3fe907

Browse files
Trottruyadorno
authored andcommitted
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: #45448 (review) PR-URL: #45466 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 160c88e commit c3fe907

10 files changed

+47
-47
lines changed

test/parallel/test-event-capture-rejections.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function NoConstructor() {
1818
name: 'TypeError',
1919
code: 'ERR_INVALID_ARG_TYPE',
2020
message: 'The "options.captureRejections" property must be of type boolean.' +
21-
common.invalidArgTypeHelper(arg)
21+
common.invalidArgTypeHelper(arg),
2222
}
2323
);
2424
});
@@ -160,7 +160,7 @@ function thenable() {
160160
assert.strictEqual(resolved, undefined);
161161
rejected(_err);
162162
});
163-
}, 1) // Only 1 call for Promises/A+ compat.
163+
}, 1), // Only 1 call for Promises/A+ compat.
164164
});
165165

166166
return obj;
@@ -235,7 +235,7 @@ function thenableThatThrows() {
235235
Object.defineProperty(obj, 'then', {
236236
get: common.mustCall(() => {
237237
throw _err;
238-
}, 1) // Only 1 call for Promises/A+ compat.
238+
}, 1), // Only 1 call for Promises/A+ compat.
239239
});
240240

241241
return obj;
@@ -301,14 +301,14 @@ function argValidation() {
301301
code: 'ERR_INVALID_ARG_TYPE',
302302
name: 'TypeError',
303303
message: 'The "options.captureRejections" property must be of type ' +
304-
`boolean. Received ${received}`
304+
`boolean. Received ${received}`,
305305
});
306306

307307
assert.throws(() => EventEmitter.captureRejections = obj, {
308308
code: 'ERR_INVALID_ARG_TYPE',
309309
name: 'TypeError',
310310
message: 'The "EventEmitter.captureRejections" property must be of ' +
311-
`type boolean. Received ${received}`
311+
`type boolean. Received ${received}`,
312312
});
313313
}
314314

test/parallel/test-event-emitter-errors.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ assert.throws(
1111
{
1212
code: 'ERR_UNHANDLED_ERROR',
1313
name: 'Error',
14-
message: "Unhandled error. ('Accepts a string')"
14+
message: "Unhandled error. ('Accepts a string')",
1515
}
1616
);
1717

@@ -20,18 +20,18 @@ assert.throws(
2020
{
2121
code: 'ERR_UNHANDLED_ERROR',
2222
name: 'Error',
23-
message: "Unhandled error. ({ message: 'Error!' })"
23+
message: "Unhandled error. ({ message: 'Error!' })",
2424
}
2525
);
2626

2727
assert.throws(
2828
() => EE.emit('error', {
2929
message: 'Error!',
30-
[util.inspect.custom]() { throw new Error(); }
30+
[util.inspect.custom]() { throw new Error(); },
3131
}),
3232
{
3333
code: 'ERR_UNHANDLED_ERROR',
3434
name: 'Error',
35-
message: 'Unhandled error. ([object Object])'
35+
message: 'Unhandled error. ([object Object])',
3636
}
3737
);

test/parallel/test-event-emitter-invalid-listener.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ for (const method of eventsMethods) {
1515
code: 'ERR_INVALID_ARG_TYPE',
1616
name: 'TypeError',
1717
message: 'The "listener" argument must be of type function. ' +
18-
'Received null'
18+
'Received null',
1919
}, `event.${method}('foo', null) should throw the proper error`);
2020
}

test/parallel/test-event-emitter-max-listeners.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ for (const obj of throwsObjs) {
4040
code: 'ERR_OUT_OF_RANGE',
4141
name: 'RangeError',
4242
message: 'The value of "n" is out of range. ' +
43-
`It must be a non-negative number. Received ${inspect(obj)}`
43+
`It must be a non-negative number. Received ${inspect(obj)}`,
4444
}
4545
);
4646

@@ -50,7 +50,7 @@ for (const obj of throwsObjs) {
5050
code: 'ERR_OUT_OF_RANGE',
5151
name: 'RangeError',
5252
message: 'The value of "defaultMaxListeners" is out of range. ' +
53-
`It must be a non-negative number. Received ${inspect(obj)}`
53+
`It must be a non-negative number. Received ${inspect(obj)}`,
5454
}
5555
);
5656
}

test/parallel/test-eventemitter-asyncresource.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function makeHook(trackedTypes) {
4141

4242
before(asyncId) { log(asyncId, 'before'); },
4343
after(asyncId) { log(asyncId, 'after'); },
44-
destroy(asyncId) { log(asyncId, 'destroy'); }
44+
destroy(asyncId) { log(asyncId, 'destroy'); },
4545
}).enable();
4646

4747
return {
@@ -51,7 +51,7 @@ function makeHook(trackedTypes) {
5151
},
5252
ids() {
5353
return new Set(eventMap.keys());
54-
}
54+
},
5555
};
5656
}
5757

@@ -150,7 +150,7 @@ throws(
150150
code: 'ERR_INVALID_THIS',
151151
name: /TypeError/,
152152
message: 'Value of "this" must be of type EventEmitterAsyncResource',
153-
stack: new RegExp(`at get ${getter}`)
153+
stack: new RegExp(`at get ${getter}`),
154154
}
155155
);
156156
});

test/parallel/test-events-on-async-iterator.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const common = require('../common');
55
const assert = require('assert');
66
const { on, EventEmitter } = require('events');
77
const {
8-
NodeEventTarget
8+
NodeEventTarget,
99
} = require('internal/event_target');
1010

1111
async function basic() {
@@ -131,18 +131,18 @@ async function next() {
131131

132132
assert.deepStrictEqual(results, [{
133133
value: ['bar'],
134-
done: false
134+
done: false,
135135
}, {
136136
value: [42],
137-
done: false
137+
done: false,
138138
}, {
139139
value: undefined,
140-
done: true
140+
done: true,
141141
}]);
142142

143143
assert.deepStrictEqual(await iterable.next(), {
144144
value: undefined,
145-
done: true
145+
done: true,
146146
});
147147
}
148148

@@ -160,19 +160,19 @@ async function nextError() {
160160
]);
161161
assert.deepStrictEqual(results, [{
162162
status: 'rejected',
163-
reason: _err
163+
reason: _err,
164164
}, {
165165
status: 'fulfilled',
166166
value: {
167167
value: undefined,
168-
done: true
169-
}
168+
done: true,
169+
},
170170
}, {
171171
status: 'fulfilled',
172172
value: {
173173
value: undefined,
174-
done: true
175-
}
174+
done: true,
175+
},
176176
}]);
177177
assert.strictEqual(ee.listeners('error').length, 0);
178178
}
@@ -196,7 +196,7 @@ async function iterableThrow() {
196196
}, {
197197
message: 'The "EventEmitter.AsyncIterator" property must be' +
198198
' an instance of Error. Received undefined',
199-
name: 'TypeError'
199+
name: 'TypeError',
200200
});
201201

202202
const expected = [['bar'], [42]];
@@ -258,11 +258,11 @@ async function abortableOnBefore() {
258258
const abortedSignal = AbortSignal.abort();
259259
[1, {}, null, false, 'hi'].forEach((signal) => {
260260
assert.throws(() => on(ee, 'foo', { signal }), {
261-
code: 'ERR_INVALID_ARG_TYPE'
261+
code: 'ERR_INVALID_ARG_TYPE',
262262
});
263263
});
264264
assert.throws(() => on(ee, 'foo', { signal: abortedSignal }), {
265-
name: 'AbortError'
265+
name: 'AbortError',
266266
});
267267
}
268268

@@ -271,11 +271,11 @@ async function eventTargetAbortableOnBefore() {
271271
const abortedSignal = AbortSignal.abort();
272272
[1, {}, null, false, 'hi'].forEach((signal) => {
273273
assert.throws(() => on(et, 'foo', { signal }), {
274-
code: 'ERR_INVALID_ARG_TYPE'
274+
code: 'ERR_INVALID_ARG_TYPE',
275275
});
276276
});
277277
assert.throws(() => on(et, 'foo', { signal: abortedSignal }), {
278-
name: 'AbortError'
278+
name: 'AbortError',
279279
});
280280
}
281281

test/parallel/test-events-once.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,12 @@ async function abortSignalBefore() {
165165

166166
await Promise.all([1, {}, 'hi', null, false].map((signal) => {
167167
return rejects(once(ee, 'foo', { signal }), {
168-
code: 'ERR_INVALID_ARG_TYPE'
168+
code: 'ERR_INVALID_ARG_TYPE',
169169
});
170170
}));
171171

172172
return rejects(once(ee, 'foo', { signal: abortedSignal }), {
173-
name: 'AbortError'
173+
name: 'AbortError',
174174
});
175175
}
176176

@@ -179,7 +179,7 @@ async function abortSignalAfter() {
179179
const ac = new AbortController();
180180
ee.on('error', common.mustNotCall());
181181
const r = rejects(once(ee, 'foo', { signal: ac.signal }), {
182-
name: 'AbortError'
182+
name: 'AbortError',
183183
});
184184
process.nextTick(() => ac.abort());
185185
return r;
@@ -217,20 +217,20 @@ async function eventTargetAbortSignalBefore() {
217217

218218
await Promise.all([1, {}, 'hi', null, false].map((signal) => {
219219
return rejects(once(et, 'foo', { signal }), {
220-
code: 'ERR_INVALID_ARG_TYPE'
220+
code: 'ERR_INVALID_ARG_TYPE',
221221
});
222222
}));
223223

224224
return rejects(once(et, 'foo', { signal: abortedSignal }), {
225-
name: 'AbortError'
225+
name: 'AbortError',
226226
});
227227
}
228228

229229
async function eventTargetAbortSignalAfter() {
230230
const et = new EventTarget();
231231
const ac = new AbortController();
232232
const r = rejects(once(et, 'foo', { signal: ac.signal }), {
233-
name: 'AbortError'
233+
name: 'AbortError',
234234
});
235235
process.nextTick(() => ac.abort());
236236
return r;

test/parallel/test-events-static-geteventlisteners.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { kWeakHandler } = require('internal/event_target');
55

66
const {
77
deepStrictEqual,
8-
throws
8+
throws,
99
} = require('assert');
1010

1111
const { getEventListeners, EventEmitter } = require('events');

test/parallel/test-eventtarget-memoryleakwarning.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const common = require('../common');
44
const {
55
setMaxListeners,
6-
EventEmitter
6+
EventEmitter,
77
} = require('events');
88
const assert = require('assert');
99

test/parallel/test-eventtarget.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ let asyncTest = Promise.resolve();
6565
code: 'ERR_INVALID_ARG_TYPE',
6666
name: 'TypeError',
6767
message: 'The "options" argument must be of type object.' +
68-
common.invalidArgTypeHelper(i)
68+
common.invalidArgTypeHelper(i),
6969
})
7070
));
7171
}
@@ -141,7 +141,7 @@ let asyncTest = Promise.resolve();
141141
handleEvent: common.mustCall(function(event) {
142142
strictEqual(event.type, 'foo');
143143
strictEqual(this, ev2);
144-
})
144+
}),
145145
};
146146

147147
eventTarget.addEventListener('foo', ev1);
@@ -318,15 +318,15 @@ let asyncTest = Promise.resolve();
318318
code: 'ERR_INVALID_ARG_TYPE',
319319
name: 'TypeError',
320320
message: 'The "event" argument must be an instance of Event.' +
321-
common.invalidArgTypeHelper(i)
321+
common.invalidArgTypeHelper(i),
322322
});
323323
});
324324

325325
const err = (arg) => ({
326326
code: 'ERR_INVALID_ARG_TYPE',
327327
name: 'TypeError',
328328
message: 'The "listener" argument must be an instance of EventListener.' +
329-
common.invalidArgTypeHelper(arg)
329+
common.invalidArgTypeHelper(arg),
330330
});
331331

332332
[
@@ -388,7 +388,7 @@ let asyncTest = Promise.resolve();
388388
const event = new Event('foo');
389389
target1.addEventListener('foo', common.mustCall((event) => {
390390
throws(() => target2.dispatchEvent(event), {
391-
code: 'ERR_EVENT_RECURSION'
391+
code: 'ERR_EVENT_RECURSION',
392392
});
393393
}));
394394
target1.dispatchEvent(event);
@@ -486,7 +486,7 @@ let asyncTest = Promise.resolve();
486486
/a/,
487487
].forEach((i) => {
488488
throws(() => target.dispatchEvent.call(i, event), {
489-
code: 'ERR_INVALID_THIS'
489+
code: 'ERR_INVALID_THIS',
490490
});
491491
});
492492
}
@@ -636,20 +636,20 @@ let asyncTest = Promise.resolve();
636636
{
637637
const ev = new Event('test');
638638
const evConstructorName = inspect(ev, {
639-
depth: -1
639+
depth: -1,
640640
});
641641
strictEqual(evConstructorName, 'Event');
642642

643643
const inspectResult = inspect(ev, {
644-
depth: 1
644+
depth: 1,
645645
});
646646
ok(inspectResult.includes('Event'));
647647
}
648648

649649
{
650650
const et = new EventTarget();
651651
const inspectResult = inspect(et, {
652-
depth: 1
652+
depth: 1,
653653
});
654654
ok(inspectResult.includes('EventTarget'));
655655
}

0 commit comments

Comments
 (0)