diff options
author | cjihrig <cjihrig@gmail.com> | 2016-08-18 16:25:34 -0400 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2016-09-09 19:50:56 -0400 |
commit | e57ff455e25d61555298cacbb0ff964e197ace10 (patch) | |
tree | ad6b4158751792414f391b8c5e49c168bc15b80c /test/parallel/test-event-emitter-once.js | |
parent | cc00be6aceac5eb8bb135c32da99eaf217b29a24 (diff) | |
download | android-node-v8-e57ff455e25d61555298cacbb0ff964e197ace10.tar.gz android-node-v8-e57ff455e25d61555298cacbb0ff964e197ace10.tar.bz2 android-node-v8-e57ff455e25d61555298cacbb0ff964e197ace10.zip |
test: exercise EE function type checking paths
This commit adds tests for on(), once(), removeListener(),
and prependOnceListener(), which all throw a TypeError if
the listener argument is not a function.
PR-URL: https://github.com/nodejs/node/pull/8168
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-event-emitter-once.js')
-rw-r--r-- | test/parallel/test-event-emitter-once.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/test/parallel/test-event-emitter-once.js b/test/parallel/test-event-emitter-once.js index 1da57ad45d..cca21a454b 100644 --- a/test/parallel/test-event-emitter-once.js +++ b/test/parallel/test-event-emitter-once.js @@ -1,8 +1,9 @@ 'use strict'; const common = require('../common'); -var events = require('events'); +const assert = require('assert'); +const EventEmitter = require('events'); -var e = new events.EventEmitter(); +const e = new EventEmitter(); e.once('hello', common.mustCall(function(a, b) {})); @@ -26,3 +27,10 @@ e.once('e', common.mustCall(function() { e.once('e', common.mustCall(function() {})); e.emit('e'); + +// Verify that the listener must be a function +assert.throws(() => { + const ee = new EventEmitter(); + + ee.once('foo', null); +}, /^TypeError: "listener" argument must be a function$/); |