diff --git a/Gruntfile.js b/Gruntfile.js index 38f4db48f..5d59aaf3f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -128,6 +128,7 @@ module.exports = function (grunt) { 'test/main/diff.js', 'test/main/dump.js', 'test/main/each.js', + 'test/main/events.js', 'test/main/HtmlReporter.js', 'test/main/modules.js', 'test/main/modules-es2018.js', diff --git a/src/events.js b/src/events.js index fe02b3a24..81d6a2174 100644 --- a/src/events.js +++ b/src/events.js @@ -28,6 +28,7 @@ const MEMORY_EVENTS = [ * @return {void} */ export function emit (eventName, data) { + /* istanbul ignore if: private function */ if (typeof eventName !== 'string') { throw new TypeError('eventName must be a string when emitting an event'); } diff --git a/test/index-es5.html b/test/index-es5.html index b7ea181fc..b18da4dfc 100644 --- a/test/index-es5.html +++ b/test/index-es5.html @@ -20,6 +20,7 @@ + diff --git a/test/index-xhtml.xhtml b/test/index-xhtml.xhtml index e566f1db2..c441262be 100644 --- a/test/index-xhtml.xhtml +++ b/test/index-xhtml.xhtml @@ -32,6 +32,7 @@ + diff --git a/test/index.html b/test/index.html index c0807c405..62c9ca523 100644 --- a/test/index.html +++ b/test/index.html @@ -20,6 +20,7 @@ + diff --git a/test/main/assert-step.js b/test/main/assert-step.js index 3972aed7f..383b29708 100644 --- a/test/main/assert-step.js +++ b/test/main/assert-step.js @@ -116,6 +116,10 @@ QUnit.module('assert.step', function () { assert.verifySteps(['two']); }); + QUnit.test('empty verifySteps()', function (assert) { + assert.verifySteps([]); + }); + QUnit.test('errors if not called when `assert.step` is used', function (assert) { assert.expect(2); assert.step('one'); diff --git a/test/main/events.js b/test/main/events.js new file mode 100644 index 000000000..e01a26764 --- /dev/null +++ b/test/main/events.js @@ -0,0 +1,25 @@ +QUnit.module('events', function () { + QUnit.test('QUnit.on [failure]', function (assert) { + assert.throws(function () { + QUnit.on(null, function () { + assert.step('null called'); + }); + }, /must be a string/, 'null event name'); + + assert.throws(function () { + QUnit.on('banana', function () { + assert.step('banana called'); + }); + }, /not a valid event/, 'unknown event name'); + + assert.throws(function () { + QUnit.on('runStart'); + }, /must be a function/, 'missing callback'); + + assert.throws(function () { + QUnit.on('runStart', null); + }, /must be a function/, 'null callback'); + + assert.verifySteps([]); + }); +}); diff --git a/test/mozjs.js b/test/mozjs.js index 4c9f83a4f..3ef2db4b4 100644 --- a/test/mozjs.js +++ b/test/mozjs.js @@ -22,6 +22,7 @@ loadRelativeToScript('../test/main/deepEqual.js'); loadRelativeToScript('../test/main/diff.js'); loadRelativeToScript('../test/main/dump.js'); loadRelativeToScript('../test/main/each.js'); +loadRelativeToScript('../test/main/events.js'); loadRelativeToScript('../test/main/HtmlReporter.js'); // loadRelativeToScript( "../test/main/modules.js" ); // Requires setTimeout loadRelativeToScript('../test/main/modules-es2018.js'); diff --git a/test/mozjs.mjs b/test/mozjs.mjs index 58d540178..0e0440a3a 100644 --- a/test/mozjs.mjs +++ b/test/mozjs.mjs @@ -11,6 +11,7 @@ import '../test/main/deepEqual.js'; import '../test/main/diff.js'; import '../test/main/dump.js'; import '../test/main/each.js'; +import '../test/main/events.js'; import '../test/main/HtmlReporter.js'; // import "../test/main/modules.js"; // Requires setTimeout import '../test/main/modules-es2018.js'; diff --git a/test/webWorker-worker.js b/test/webWorker-worker.js index 69e92a5da..1f8954fbe 100644 --- a/test/webWorker-worker.js +++ b/test/webWorker-worker.js @@ -16,6 +16,7 @@ importScripts( 'main/diff.js', 'main/dump.js', 'main/each.js', + 'main/events.js', 'main/HtmlReporter.js', 'main/modules.js', 'main/modules-es2018.js',