From 2bd4bc0984abab28a61c84214e5ae2bf553a8451 Mon Sep 17 00:00:00 2001 From: Erik Trom Date: Tue, 27 Feb 2018 21:13:30 -0800 Subject: [PATCH] Add `QUnit.todo(name, callback)` function signature - see https://api.qunitjs.com/QUnit/todo for docs used @waratuman - I've only added this function to the interface, but I bumped the type definitions for QUnit at the top of the file from `v2.0.1` to `v2.5.0`. This may not accurately reflect the 2.5.0 QUnit api in full, fyi. (advise if this concerns you). --- types/qunit/index.d.ts | 17 ++++++++++++++++- types/qunit/qunit-tests.ts | 4 ++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/types/qunit/index.d.ts b/types/qunit/index.d.ts index d793a68c3e..a0276a3488 100644 --- a/types/qunit/index.d.ts +++ b/types/qunit/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for QUnit v2.0.1 +// Type definitions for QUnit v2.5.0 // Project: http://qunitjs.com/ // Definitions by: James Bracy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -580,6 +580,21 @@ interface QUnit { */ testStart(callback: (details: { name: string; module: string;}) => void): void; + /** + * Adds a test which expects at least one failing assertion during its run. + * + * Use this method to test a unit of code which is still under development + * (in a “todo” state). The test will pass as long as one failing assertion + * is present. + * + * If all assertions pass, then the test will fail signaling that QUnit.todo + * should be replaced by QUnit.test. + * + * @param {string} Title of unit being tested + * @param callback Function to close over assertions + */ + todo(name: string, callback?: (assert: Assert) => void): void; + /** * Are the test running from the server or not. */ diff --git a/types/qunit/qunit-tests.ts b/types/qunit/qunit-tests.ts index f6b645875f..25ffc9fbf1 100644 --- a/types/qunit/qunit-tests.ts +++ b/types/qunit/qunit-tests.ts @@ -552,3 +552,7 @@ QUnit.module( "module", { QUnit.test( "test with beforeEach and afterEach", function( assert ) { assert.expect( 2 ); }); + +QUnit.todo( "a todo test", function( assert ) { + assert.equal( 0, 1, "0 does not equal 1, so this todo should pass" ); +});