mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Type definitions for QUnit 1.10.0 was added.
This commit is contained in:
Vendored
+130
@@ -0,0 +1,130 @@
|
||||
// Type definitions for QUnit 1.10.0
|
||||
// Project: http://qunitjs.com/
|
||||
// @by: Diullei Gomes <https://github.com/diullei>
|
||||
|
||||
interface DoneCallbackObject {
|
||||
failed: number;
|
||||
passed: number;
|
||||
total: number;
|
||||
runtime: number;
|
||||
}
|
||||
|
||||
interface LogCallbackObject {
|
||||
result: bool;
|
||||
actual: Object;
|
||||
expected: Object;
|
||||
message: string;
|
||||
}
|
||||
|
||||
interface ModuleDoneCallbackObject {
|
||||
name: string;
|
||||
failed: number;
|
||||
passed: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
interface TestDoneCallbackObject {
|
||||
name: string;
|
||||
module: string;
|
||||
failed: number;
|
||||
passed: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
interface TestStartCallbackObject {
|
||||
name: string;
|
||||
module: string;
|
||||
failed: number;
|
||||
passed: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
interface Config {
|
||||
altertitle: bool;
|
||||
autostart: bool;
|
||||
current: Object;
|
||||
reorder: bool;
|
||||
requireExpects: bool;
|
||||
urlConfig: Array;
|
||||
}
|
||||
|
||||
interface LifecycleObject {
|
||||
setup: () => any;
|
||||
teardown: () => any;
|
||||
}
|
||||
|
||||
interface QUnitAssert {
|
||||
/* ASSERT */
|
||||
deepEqual(actual: Object, expected: Object, message: string);
|
||||
equal(actual: Object, expected: Object, message: string);
|
||||
notDeepEqual(actual: Object, expected: Object, message: string);
|
||||
notEqual(actual: Object, expected: Object, message: string);
|
||||
notStrictEqual(actual: Object, expected: Object, message: string);
|
||||
ok(state: any, message: string);
|
||||
strictEqual(actual: Object, expected: Object, message: string);
|
||||
throws(block: () => any, expected: Object, message: string);
|
||||
throws(block: () => any, message: string);
|
||||
}
|
||||
|
||||
interface QUnitStatic extends QUnitAssert{
|
||||
/* ASYNC CONTROL */
|
||||
start(decrement?: number);
|
||||
stop(increment? : number);
|
||||
|
||||
/* CALLBACKS */
|
||||
begin(callback: () => any);
|
||||
done(callback: (details: DoneCallbackObject) => any);
|
||||
log(callback: (details: LogCallbackObject) => any);
|
||||
moduleDone(callback: (details: ModuleDoneCallbackObject) => any);
|
||||
moduleStart(callback: (name: string) => any);
|
||||
testDone(callback: (details: TestDoneCallbackObject) => any);
|
||||
testStart(callback: (details: TestStartCallbackObject) => any);
|
||||
|
||||
/* CONFIGURATION */
|
||||
config: Config;
|
||||
|
||||
/* TEST */
|
||||
asyncTest(name: string, expected: number, test: () => any);
|
||||
asyncTest(name: string, test: () => any);
|
||||
expect(amount: number);
|
||||
module(name: string, lifecycle?: LifecycleObject);
|
||||
test(title: string, expected: number, test: (assert: any) => any);
|
||||
test(title: string, test: (assert: any) => any);
|
||||
}
|
||||
|
||||
/* ASSERT */
|
||||
declare var deepEqual: (actual: Object, expected: Object, message: string) => any;
|
||||
declare var equal: (actual: Object, expected: Object, message: string) => any;
|
||||
declare var notDeepEqual: (actual: Object, expected: Object, message: string) => any;
|
||||
declare var notEqual: (actual: Object, expected: Object, message: string) => any;
|
||||
declare var notStrictEqual: (actual: Object, expected: Object, message: string) => any;
|
||||
declare var ok: (state: any, message: string) => any;
|
||||
declare var strictEqual: (actual: Object, expected: Object, message: string) => any;
|
||||
// ** I Can't make overload here! :(
|
||||
//declare var throws: (block: () => void, expected: Object, message: string) => any;
|
||||
declare var throws: (block: () => void, message: string) => any;
|
||||
|
||||
/* ASYNC CONTROL */
|
||||
declare var start: (decrement?: number) => any;
|
||||
declare var stop: (increment? : number) => any;
|
||||
|
||||
/* CALLBACKS */
|
||||
declare var begin: (callback: () => any) => any;
|
||||
declare var done: (callback: (details: DoneCallbackObject) => any) => any;
|
||||
declare var log: (callback: (details: LogCallbackObject) => any) => any;
|
||||
declare var moduleDone: (callback: (details: ModuleDoneCallbackObject) => any) => any;
|
||||
declare var moduleStart: (callback: (name: string) => any) => any;
|
||||
declare var testDone: (callback: (details: TestDoneCallbackObject) => any) => any;
|
||||
declare var testStart: (callback: (details: TestStartCallbackObject) => any) => any;
|
||||
|
||||
/* TEST */
|
||||
declare var asyncTest: (name: string, /*expected?: number, */test: () => any) => any;
|
||||
declare var expect: (amount: number) => any;
|
||||
// ** conflict with TypeScript module keyword. Must be used on QUnit namespace
|
||||
//declare var module: (name: string, lifecycle?: LifecycleObject) => any;
|
||||
// ** I can't make an overload here! :(
|
||||
//declare var test: (title: string, expected: number, test: (assert?: any) => any) => any;
|
||||
declare var test: (title: string, test: (assert?: any) => any) => any;
|
||||
|
||||
/* QUNIT */
|
||||
declare var QUnit: QUnitStatic;
|
||||
@@ -0,0 +1,164 @@
|
||||
/// <reference path="../Definitions/qunit-1.10.0.d.ts" />
|
||||
|
||||
QUnit.test( "deepEqual test", function() {
|
||||
var obj = { foo: "bar" };
|
||||
|
||||
QUnit.deepEqual( obj, { foo: "bar" }, "Two objects can be the same in value" );
|
||||
});
|
||||
|
||||
test( "deepEqual test", function() {
|
||||
var obj = { foo: "bar" };
|
||||
|
||||
deepEqual( obj, { foo: "bar" }, "Two objects can be the same in value" );
|
||||
});
|
||||
|
||||
QUnit.test( "a test", function() {
|
||||
QUnit.equal( 1, "1", "String '1' and number 1 have the same value" );
|
||||
});
|
||||
|
||||
test( "a test", function() {
|
||||
equal( 1, "1", "String '1' and number 1 have the same value" );
|
||||
});
|
||||
|
||||
QUnit.test( "equal test", function() {
|
||||
QUnit.equal( 0, 0, "Zero; equal succeeds" );
|
||||
QUnit.equal( "", 0, "Empty, Zero; equal succeeds" );
|
||||
QUnit.equal( "", "", "Empty, Empty; equal succeeds" );
|
||||
QUnit.equal( 0, 0, "Zero, Zero; equal succeeds" );
|
||||
|
||||
QUnit.equal( "three", 3, "Three, 3; equal fails" );
|
||||
QUnit.equal( null, false, "null, false; equal fails" );
|
||||
});
|
||||
|
||||
test( "equal test", function() {
|
||||
equal( 0, 0, "Zero; equal succeeds" );
|
||||
equal( "", 0, "Empty, Zero; equal succeeds" );
|
||||
equal( "", "", "Empty, Empty; equal succeeds" );
|
||||
equal( 0, 0, "Zero, Zero; equal succeeds" );
|
||||
|
||||
equal( "three", 3, "Three, 3; equal fails" );
|
||||
equal( null, false, "null, false; equal fails" );
|
||||
});
|
||||
|
||||
QUnit.test( "notDeepEqual test", function() {
|
||||
var obj = { foo: "bar" };
|
||||
|
||||
QUnit.notDeepEqual( obj, { foo: "bla" }, "Different object, same key, different value, not equal" );
|
||||
});
|
||||
|
||||
test( "notDeepEqual test", function() {
|
||||
var obj = { foo: "bar" };
|
||||
|
||||
notDeepEqual( obj, { foo: "bla" }, "Different object, same key, different value, not equal" );
|
||||
});
|
||||
|
||||
QUnit.test( "a test", function() {
|
||||
QUnit.notEqual( 1, "2", "String '2' and number 1 don't have the same value" );
|
||||
});
|
||||
|
||||
test( "a test", function() {
|
||||
notEqual( 1, "2", "String '2' and number 1 don't have the same value" );
|
||||
});
|
||||
|
||||
QUnit.test( "a test", function() {
|
||||
QUnit.notStrictEqual( 1, "1", "String '1' and number 1 don't have the same value" );
|
||||
});
|
||||
|
||||
test( "a test", function() {
|
||||
notStrictEqual( 1, "1", "String '1' and number 1 don't have the same value" );
|
||||
});
|
||||
|
||||
QUnit.test( "ok test", function() {
|
||||
QUnit.ok( true, "true succeeds" );
|
||||
QUnit.ok( "non-empty", "non-empty string succeeds" );
|
||||
|
||||
QUnit.ok( false, "false fails" );
|
||||
QUnit.ok( 0, "0 fails" );
|
||||
QUnit.ok( NaN, "NaN fails" );
|
||||
QUnit.ok( "", "empty string fails" );
|
||||
QUnit.ok( null, "null fails" );
|
||||
QUnit.ok( undefined, "undefined fails" );
|
||||
});
|
||||
|
||||
test( "ok test", function() {
|
||||
ok( true, "true succeeds" );
|
||||
ok( "non-empty", "non-empty string succeeds" );
|
||||
|
||||
ok( false, "false fails" );
|
||||
ok( 0, "0 fails" );
|
||||
ok( NaN, "NaN fails" );
|
||||
ok( "", "empty string fails" );
|
||||
ok( null, "null fails" );
|
||||
ok( undefined, "undefined fails" );
|
||||
});
|
||||
|
||||
QUnit.test( "strictEqual test", function() {
|
||||
QUnit.strictEqual( 1, 1, "1 and 1 are the same value and type" );
|
||||
});
|
||||
|
||||
test( "strictEqual test", function() {
|
||||
strictEqual( 1, 1, "1 and 1 are the same value and type" );
|
||||
});
|
||||
|
||||
QUnit.test( "a test", function() {
|
||||
QUnit.stop();
|
||||
QUnit.start();
|
||||
});
|
||||
|
||||
test( "a test", function() {
|
||||
stop();
|
||||
start();
|
||||
});
|
||||
|
||||
QUnit.config.autostart = false;
|
||||
QUnit.start();
|
||||
|
||||
QUnit.config.urlConfig.push({
|
||||
id: "min",
|
||||
label: "Minified source",
|
||||
tooltip: "Load minified source files instead of the regular unminified ones."
|
||||
});
|
||||
|
||||
QUnit.asyncTest( "asynchronous test: one second later!", function() {
|
||||
QUnit.expect( 1 );
|
||||
});
|
||||
|
||||
asyncTest( "asynchronous test: one second later!", function() {
|
||||
expect( 1 );
|
||||
});
|
||||
|
||||
QUnit.module( "group a" );
|
||||
QUnit.test( "a basic test example", function() {
|
||||
QUnit.ok( true, "this test is fine" );
|
||||
});
|
||||
QUnit.test( "a basic test example 2", function() {
|
||||
QUnit.ok( true, "this test is fine" );
|
||||
});
|
||||
|
||||
QUnit.module( "group b" );
|
||||
QUnit.test( "a basic test example 3", function() {
|
||||
QUnit.ok( true, "this test is fine" );
|
||||
});
|
||||
QUnit.test( "a basic test example 4", function() {
|
||||
QUnit.ok( true, "this test is fine" );
|
||||
});
|
||||
|
||||
QUnit.module( "module A", {
|
||||
setup: function() {
|
||||
// prepare something for all following tests
|
||||
},
|
||||
teardown: function() {
|
||||
// clean up after each test
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test( "a test", function( assert ) {
|
||||
|
||||
function square( x ) {
|
||||
return x * x;
|
||||
}
|
||||
|
||||
var result = square( 2 );
|
||||
|
||||
assert.equal( result, 4, "square(2) equals 4" );
|
||||
});
|
||||
Reference in New Issue
Block a user