diff --git a/qunit/qunit-tests.ts b/qunit/qunit-tests.ts
index abc1af8c71..dd0335aedc 100644
--- a/qunit/qunit-tests.ts
+++ b/qunit/qunit-tests.ts
@@ -1,5 +1,14 @@
///
+QUnit.test("assert.async() test", function (assert) {
+ var done = assert.async();
+ var input = [];
+ setTimeout(function () {
+ assert.equal(document.activeElement, input[0], "Input was focused");
+ done();
+ });
+});
+
QUnit.test("deepEqual test", function () {
var obj = { foo: "bar" };
@@ -229,6 +238,14 @@ test( "throws", function() {
);
});
+QUnit.test("raises", function () {
+ QUnit.test("raises, alias for throws", function (assert) {
+ assert.expect(1);
+ assert.raises(function () {
+ throw "my error";
+ });
+ });
+});
QUnit.module("equiv");
@@ -1355,95 +1372,6 @@ QUnit.test("propEqual", 5, function( assert ) {
);
});
-QUnit.test("raises", 9, function() {
- function CustomError( message ) {
- this.message = message;
- }
-
- CustomError.prototype.toString = function() {
- return this.message;
- };
-
- throws(
- function() {
- throw "my error";
- }
- );
-
- throws(
- function() {
- throw "my error";
- },
- "simple string throw, no 'expected' value given"
- );
-
- // This test is for IE 7 and prior which does not properly
- // implement Error.prototype.toString
- throws(
- function() {
- throw new Error("error message");
- },
- /error message/,
- "use regexp against instance of Error"
- );
-
- throws(
- function() {
- throw new Error();
- },
- Error,
- 'thrown error is an instance of CustomError'
- );
-
- throws(
- function() {
- throw new Error("some error description");
- },
- /description/,
- "use a regex to match against the stringified error"
- );
-
- throws(
- function() {
- throw new Error("some error description");
- },
- function( err ) {
- if ( (err instanceof Error) && /description/.test(err) ) {
- return true;
- }
- },
- "custom validation function"
- );
-
- throws(
- function() {
- /*jshint evil:true */
- ( window.execScript || function( data ) {
- window["eval"].call( window, data );
- })( "throw 'error';" );
- },
- 'globally-executed errors caught'
- );
-
- this.CustomError = {};
-
- throws(
- function() {
- throw new this.CustomError("some error description");
- },
- /description/,
- "throw error from property of 'this' context"
- );
-
- raises(
- function() {
- throw "error";
- },
- "simple throw, asserting with deprecated raises() function"
- );
-
-});
-
if (typeof document !== "undefined") {
QUnit.module("fixture");
diff --git a/qunit/qunit.d.ts b/qunit/qunit.d.ts
index c6fe34f0f7..dbf5d9c087 100644
--- a/qunit/qunit.d.ts
+++ b/qunit/qunit.d.ts
@@ -1,4 +1,4 @@
-// Type definitions for QUnit 1.10
+// Type definitions for QUnit v1.16
// Project: http://qunitjs.com/
// Definitions by: Diullei Gomes
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -163,6 +163,15 @@ interface QUnitAssert {
current_testEnvironment: any;
jsDump: any;
+ /**
+ * Instruct QUnit to wait for an asynchronous operation.
+ *
+ * When your test has any asynchronous exit points, call assert.async() to get a unique
+ * resolution callback for each async operation. The callback returned from assert.async()
+ * will throw an Error if is invoked more than once.
+ */
+ async(): any;
+
/**
* A deep recursive comparison assertion, working on primitive types, arrays, objects,
* regular expressions, dates and functions.
@@ -189,7 +198,18 @@ interface QUnitAssert {
* @param expected Known comparison value
* @param message A short description of the assertion
*/
- equal(actual: any, expected: any, message?: string): any;
+ equal(actual: any, expected: any, message?: string): any;
+
+ /**
+ * Specify how many assertions are expected to run within a test.
+ *
+ * To ensure that an explicit number of assertions are run within any test, use
+ * expect( number ) to register an expected count. If the number of assertions
+ * run does not match the expected count, the test will fail.
+ *
+ * @param amount Number of assertions in this test.
+ */
+ expect(amount: number): any;
/**
* An inverted deep recursive comparison assertion, working on primitive types,
@@ -279,9 +299,34 @@ interface QUnitAssert {
* @param message A short description of the assertion
*/
throws(block: () => any, message?: string): any;
+
+ /**
+ * Alias of throws.
+ *
+ * In very few environments, like Closure Compiler, throws is considered a reserved word
+ * and will cause an error. For that case, an alias is bundled called raises. It has the
+ * same signature and behaviour, just a different name.
+ *
+ * @param block Function to execute
+ * @param expected Error Object to compare
+ * @param message A short description of the assertion
+ */
+ raises(block: () => any, expected: any, message?: string): any;
+
+ /**
+ * Alias of throws.
+ *
+ * In very few environments, like Closure Compiler, throws is considered a reserved word
+ * and will cause an error. For that case, an alias is bundled called raises. It has the
+ * same signature and behaviour, just a different name.
+ *
+ * @param block Function to execute
+ * @param message A short description of the assertion
+ */
+ raises(block: () => any, message?: string): any;
}
-interface QUnitStatic extends QUnitAssert{
+interface QUnitStatic extends QUnitAssert {
/* ASYNC CONTROL */
/**
@@ -402,6 +447,7 @@ interface QUnitStatic extends QUnitAssert{
* run does not match the expected count, the test will fail.
*
* @param amount Number of assertions in this test.
+ * @depricated since version 1.16
*/
expect(amount: number): any;
@@ -442,9 +488,6 @@ interface QUnitStatic extends QUnitAssert{
*/
equiv(a: any, b: any): any;
- // https://github.com/jquery/qunit/blob/master/qunit/qunit.js#L661
- raises: any;
-
/**
* https://github.com/jquery/qunit/blob/master/qunit/qunit.js#L897
*/
@@ -683,6 +726,7 @@ declare function asyncTest(name: string, test: (assert: QUnitAssert) => any): an
* run does not match the expected count, the test will fail.
*
* @param amount Number of assertions in this test.
+* @depricated since version 1.16
*/
declare function expect(amount: number): any;