mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-18 04:24:30 +08:00
updated chai-assert.d.ts
fixed chai test
This commit is contained in:
@@ -33,17 +33,25 @@ THE SOFTWARE.
|
||||
///<reference path="chai-assert.d.ts" />
|
||||
|
||||
//stubs
|
||||
declare module chai {
|
||||
var AssertionError;
|
||||
function expect(body):any;
|
||||
}
|
||||
|
||||
//tdd
|
||||
declare function suite(description, action):void;
|
||||
declare function test(description, action):void;
|
||||
declare function err(action, msg?):void;
|
||||
declare function suite(description: string, action: Function):void;
|
||||
declare function test(description: string, action: Function):void;
|
||||
declare function err(action: any, msg?: string):void;
|
||||
interface FieldObj {
|
||||
field: any;
|
||||
}
|
||||
class Foo {
|
||||
constructor() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class CrashyObject {
|
||||
inspect (): void {
|
||||
throw new Error("Arg's inspect() called even though the test passed");
|
||||
}
|
||||
}
|
||||
|
||||
suite('assert', function () {
|
||||
|
||||
@@ -56,12 +64,6 @@ suite('assert', function () {
|
||||
}, "expected foo to equal `bar`");
|
||||
});
|
||||
|
||||
test('fail', function () {
|
||||
chai.expect(function () {
|
||||
assert.fail();
|
||||
}).to.throw(chai.AssertionError);
|
||||
});
|
||||
|
||||
test('isTrue', function () {
|
||||
assert.isTrue(true);
|
||||
|
||||
@@ -109,7 +111,7 @@ suite('assert', function () {
|
||||
});
|
||||
|
||||
test('equal', function () {
|
||||
var foo;
|
||||
var foo: any;
|
||||
assert.equal(foo, undefined);
|
||||
});
|
||||
|
||||
@@ -133,27 +135,15 @@ suite('assert', function () {
|
||||
});
|
||||
|
||||
test('instanceOf', function () {
|
||||
function Foo() {
|
||||
}
|
||||
|
||||
assert.instanceOf(new Foo(), Foo);
|
||||
|
||||
err(function () {
|
||||
assert.instanceOf(5, Foo);
|
||||
}, "expected 5 to be an instance of Foo");
|
||||
|
||||
function CrashyObject() {
|
||||
};
|
||||
CrashyObject.prototype.inspect = function () {
|
||||
throw new Error("Arg's inspect() called even though the test passed");
|
||||
};
|
||||
assert.instanceOf(new CrashyObject(), CrashyObject);
|
||||
});
|
||||
|
||||
test('notInstanceOf', function () {
|
||||
function Foo() {
|
||||
}
|
||||
|
||||
assert.notInstanceOf(new Foo(), String);
|
||||
|
||||
err(function () {
|
||||
@@ -162,9 +152,6 @@ suite('assert', function () {
|
||||
});
|
||||
|
||||
test('isObject', function () {
|
||||
function Foo() {
|
||||
}
|
||||
|
||||
assert.isObject({});
|
||||
assert.isObject(new Foo());
|
||||
|
||||
@@ -182,9 +169,6 @@ suite('assert', function () {
|
||||
});
|
||||
|
||||
test('isNotObject', function () {
|
||||
function Foo() {
|
||||
}
|
||||
|
||||
assert.isNotObject(5);
|
||||
|
||||
err(function () {
|
||||
|
||||
233
chai/chai-assert.d.ts
vendored
233
chai/chai-assert.d.ts
vendored
@@ -1,114 +1,135 @@
|
||||
// Type definitions for chai v1.7.0 assert style
|
||||
// Type definitions for chai v1.9.0 assert style
|
||||
// Project: http://chaijs.com/
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module chai
|
||||
{
|
||||
interface Assert
|
||||
{
|
||||
(express:any, msg?:string):void;
|
||||
|
||||
fail(actual?:any, expected?:any, msg?:string, operator?:string):void;
|
||||
|
||||
ok(val:any, msg?:string):void;
|
||||
notOk(val:any, msg?:string):void;
|
||||
|
||||
equal(act:any, exp:any, msg?:string):void;
|
||||
notEqual(act:any, exp:any, msg?:string):void;
|
||||
|
||||
strictEqual(act:any, exp:any, msg?:string):void;
|
||||
notStrictEqual(act:any, exp:any, msg?:string):void;
|
||||
|
||||
deepEqual(act:any, exp:any, msg?:string):void;
|
||||
notDeepEqual(act:any, exp:any, msg?:string):void;
|
||||
|
||||
isTrue(val:any, msg?:string):void;
|
||||
isFalse(val:any, msg?:string):void;
|
||||
|
||||
isNull(val:any, msg?:string):void;
|
||||
isNotNull(val:any, msg?:string):void;
|
||||
|
||||
isUndefined(val:any, msg?:string):void;
|
||||
isDefined(val:any, msg?:string):void;
|
||||
|
||||
isFunction(val:any, msg?:string):void;
|
||||
isNotFunction(val:any, msg?:string):void;
|
||||
|
||||
isObject(val:any, msg?:string):void;
|
||||
isNotObject(val:any, msg?:string):void;
|
||||
|
||||
isArray(val:any, msg?:string):void;
|
||||
isNotArray(val:any, msg?:string):void;
|
||||
|
||||
isString(val:any, msg?:string):void;
|
||||
isNotString(val:any, msg?:string):void;
|
||||
|
||||
isNumber(val:any, msg?:string):void;
|
||||
isNotNumber(val:any, msg?:string):void;
|
||||
|
||||
isBoolean(val:any, msg?:string):void;
|
||||
isNotBoolean(val:any, msg?:string):void;
|
||||
|
||||
typeOf(val:any, type:string, msg?:string):void;
|
||||
notTypeOf(val:any, type:string, msg?:string):void;
|
||||
|
||||
instanceOf(val:any, type:Function, msg?:string):void;
|
||||
notInstanceOf(val:any, type:Function, msg?:string):void;
|
||||
|
||||
include(exp:string, inc:any, msg?:string):void;
|
||||
include(exp:any[], inc:any, msg?:string):void;
|
||||
|
||||
notInclude(exp:string, inc:any, msg?:string):void;
|
||||
notInclude(exp:any[], inc:any, msg?:string):void;
|
||||
|
||||
match(exp:any, re:RegExp, msg?:string):void;
|
||||
notMatch(exp:any, re:RegExp, msg?:string):void;
|
||||
|
||||
property(obj:Object, prop:string, msg?:string):void;
|
||||
notProperty(obj:Object, prop:string, msg?:string):void;
|
||||
deepProperty(obj:Object, prop:string, msg?:string):void;
|
||||
notDeepProperty(obj:Object, prop:string, msg?:string):void;
|
||||
|
||||
propertyVal(obj:Object, prop:string, val:any, msg?:string):void;
|
||||
propertyNotVal(obj:Object, prop:string, val:any, msg?:string):void;
|
||||
|
||||
deepPropertyVal(obj:Object, prop:string, val:any, msg?:string):void;
|
||||
deepPropertyNotVal(obj:Object, prop:string, val:any, msg?:string):void;
|
||||
|
||||
lengthOf(exp:any, len:number, msg?:string):void;
|
||||
|
||||
//alias frenzy
|
||||
throw(fn:Function, msg?:string):void;
|
||||
throw(fn:Function, regExp:RegExp):void;
|
||||
throw(fn:Function, errType:Function, msg?:string):void;
|
||||
throw(fn:Function, errType:Function, regExp:RegExp):void;
|
||||
|
||||
throws(fn:Function, msg?:string):void;
|
||||
throws(fn:Function, regExp:RegExp):void;
|
||||
throws(fn:Function, errType:Function, msg?:string):void;
|
||||
throws(fn:Function, errType:Function, regExp:RegExp):void;
|
||||
|
||||
Throw(fn:Function, msg?:string):void;
|
||||
Throw(fn:Function, regExp:RegExp):void;
|
||||
Throw(fn:Function, errType:Function, msg?:string):void;
|
||||
Throw(fn:Function, errType:Function, regExp:RegExp):void;
|
||||
|
||||
doesNotThrow(fn:Function, msg?:string):void;
|
||||
doesNotThrow(fn:Function, regExp:RegExp):void;
|
||||
doesNotThrow(fn:Function, errType:Function, msg?:string):void;
|
||||
doesNotThrow(fn:Function, errType:Function, regExp:RegExp):void;
|
||||
|
||||
operator(val:any, operator:string, val2:any, msg?:string):void;
|
||||
closeTo(act:number, exp:number, delta:number, msg?:string):void;
|
||||
|
||||
sameMembers(set1:any[], set2:any[], msg?:string):void;
|
||||
includeMembers(set1:any[], set2:any[], msg?:string):void;
|
||||
|
||||
ifError(val:any, msg?:string):void;
|
||||
declare module chai {
|
||||
export class AssertionError {
|
||||
constructor(message: string, _props?: any, ssf?: Function);
|
||||
name: string;
|
||||
message: string;
|
||||
showDiff: boolean;
|
||||
stack: string;
|
||||
}
|
||||
export function use(plugin: any): void;
|
||||
|
||||
export var Assertion: ChaiAssertion;
|
||||
export var assert: Assert;
|
||||
export var config: ChaiConfig;
|
||||
|
||||
export interface ChaiConfig {
|
||||
includeStack: boolean;
|
||||
}
|
||||
|
||||
export interface ChaiAssertion {
|
||||
// what?
|
||||
}
|
||||
|
||||
export interface Assert {
|
||||
(express: any, msg?: string):void;
|
||||
|
||||
fail(actual?: any, expected?: any, msg?: string, operator?: string):void;
|
||||
|
||||
ok(val: any, msg?: string):void;
|
||||
notOk(val: any, msg?: string):void;
|
||||
|
||||
equal(act: any, exp: any, msg?: string):void;
|
||||
notEqual(act: any, exp: any, msg?: string):void;
|
||||
|
||||
strictEqual(act: any, exp: any, msg?: string):void;
|
||||
notStrictEqual(act: any, exp: any, msg?: string):void;
|
||||
|
||||
deepEqual(act: any, exp: any, msg?: string):void;
|
||||
notDeepEqual(act: any, exp: any, msg?: string):void;
|
||||
|
||||
isTrue(val: any, msg?: string):void;
|
||||
isFalse(val: any, msg?: string):void;
|
||||
|
||||
isNull(val: any, msg?: string):void;
|
||||
isNotNull(val: any, msg?: string):void;
|
||||
|
||||
isUndefined(val: any, msg?: string):void;
|
||||
isDefined(val: any, msg?: string):void;
|
||||
|
||||
isFunction(val: any, msg?: string):void;
|
||||
isNotFunction(val: any, msg?: string):void;
|
||||
|
||||
isObject(val: any, msg?: string):void;
|
||||
isNotObject(val: any, msg?: string):void;
|
||||
|
||||
isArray(val: any, msg?: string):void;
|
||||
isNotArray(val: any, msg?: string):void;
|
||||
|
||||
isString(val: any, msg?: string):void;
|
||||
isNotString(val: any, msg?: string):void;
|
||||
|
||||
isNumber(val: any, msg?: string):void;
|
||||
isNotNumber(val: any, msg?: string):void;
|
||||
|
||||
isBoolean(val: any, msg?: string):void;
|
||||
isNotBoolean(val: any, msg?: string):void;
|
||||
|
||||
typeOf(val: any, type: string, msg?: string):void;
|
||||
notTypeOf(val: any, type: string, msg?: string):void;
|
||||
|
||||
instanceOf(val: any, type: Function, msg?: string):void;
|
||||
notInstanceOf(val: any, type: Function, msg?: string):void;
|
||||
|
||||
include(exp: string, inc: any, msg?: string):void;
|
||||
include(exp: any[], inc: any, msg?: string):void;
|
||||
|
||||
notInclude(exp: string, inc: any, msg?: string):void;
|
||||
notInclude(exp: any[], inc: any, msg?: string):void;
|
||||
|
||||
match(exp: any, re: RegExp, msg?: string):void;
|
||||
notMatch(exp: any, re: RegExp, msg?: string):void;
|
||||
|
||||
property(obj: Object, prop: string, msg?: string):void;
|
||||
notProperty(obj: Object, prop: string, msg?: string):void;
|
||||
deepProperty(obj: Object, prop: string, msg?: string):void;
|
||||
notDeepProperty(obj: Object, prop: string, msg?: string):void;
|
||||
|
||||
propertyVal(obj: Object, prop: string, val: any, msg?: string):void;
|
||||
propertyNotVal(obj: Object, prop: string, val: any, msg?: string):void;
|
||||
|
||||
deepPropertyVal(obj: Object, prop: string, val: any, msg?: string):void;
|
||||
deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string):void;
|
||||
|
||||
lengthOf(exp: any, len: number, msg?: string):void;
|
||||
//alias frenzy
|
||||
throw(fn: Function, msg?: string):void;
|
||||
throw(fn: Function, regExp: RegExp):void;
|
||||
throw(fn: Function, errType: Function, msg?: string):void;
|
||||
throw(fn: Function, errType: Function, regExp: RegExp):void;
|
||||
|
||||
throws(fn: Function, msg?: string):void;
|
||||
throws(fn: Function, regExp: RegExp):void;
|
||||
throws(fn: Function, errType: Function, msg?: string):void;
|
||||
throws(fn: Function, errType: Function, regExp: RegExp):void;
|
||||
|
||||
Throw(fn: Function, msg?: string):void;
|
||||
Throw(fn: Function, regExp: RegExp):void;
|
||||
Throw(fn: Function, errType: Function, msg?: string):void;
|
||||
Throw(fn: Function, errType: Function, regExp: RegExp):void;
|
||||
|
||||
doesNotThrow(fn: Function, msg?: string):void;
|
||||
doesNotThrow(fn: Function, regExp: RegExp):void;
|
||||
doesNotThrow(fn: Function, errType: Function, msg?: string):void;
|
||||
doesNotThrow(fn: Function, errType: Function, regExp: RegExp):void;
|
||||
|
||||
operator(val: any, operator: string, val2: any, msg?: string):void;
|
||||
closeTo(act: number, exp: number, delta: number, msg?: string):void;
|
||||
|
||||
sameMembers(set1: any[], set2: any[], msg?: string):void;
|
||||
includeMembers(set1: any[], set2: any[], msg?: string):void;
|
||||
|
||||
ifError(val: any, msg?: string):void;
|
||||
}
|
||||
//node module
|
||||
var assert:Assert;
|
||||
}
|
||||
|
||||
//browser global
|
||||
declare var assert:chai.Assert;
|
||||
|
||||
declare module 'chai' {
|
||||
export = chai;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user