Merge pull request #7089 from DavidBR-SW/Type_Defintions_for_chai-things

Added typings for chai-things
This commit is contained in:
Masahiro Wakame
2015-12-10 22:57:06 +09:00
2 changed files with 114 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
/// <reference path="chai-things.d.ts" />
import chai = require('chai');
import chaiThings = require('chai-things');
chai.use(chaiThings);
function test_somethingSyntax() {
[].should.not.include.something();
[].should.not.include.something.that.equals(1);
var array = [{ a: 1 }, { b: 2 }];
array.should.include.something();
array.should.include.something.that.deep.equals({ b: 2 });
array.should.include.something.that.not.deep.equals({ b: 2 });
array.should.not.include.something.that.deep.equals({ c: 3 });
array.should.include.something.that.not.deep.equals({ c: 3 });
array.should.include.something.with.property('b', 2);
array.should.not.include.something.with.property('b', 3);
var array2 = [{ a: 'b' }, { a: 'b' }];
array2.should.include.something.that.have.property("a");
array2.should.include.something.that.have.property("a").not.equal("d");
}
function test_somethingVariantsSyntax() {
[].should.not.include.any();
[].should.not.include.any.that.deep.equal({ b: 2 });
var array = [{ a: 1 }, { b: 2 }];
array.should.include.a.thing();
array.should.include.a.thing.that.deep.equals({ b: 2 });
array.should.include.an.item();
array.should.include.an.item.that.deep.equals({ b: 2 });
array.should.include.one.that.deep.equals({ b: 2 });
array.should.include.some();
array.should.include.some.that.deep.equal({ b: 2 });
}
function test_allSyntax() {
[].should.all.equal(1);
[].should.all.not.equal(1);
var array = [1, 1];
array.should.all.equal(1);
array.should.all.not.equal(2);
array.should.not.all.equal(2);
array.should.not.all.not.equal(1);
var array2 = [1, 2];
array2.should.not.all.equal(1);
array2.should.not.all.equal(2);
array2.should.not.all.not.equal(1);
array2.should.not.all.not.equal(2);
var array3 = [{ a: 'b' }, { a: 'c' }];
array3.should.all.have.property("a");
array3.should.all.have.property("a").not.equal("d");
}
+55
View File
@@ -0,0 +1,55 @@
// Type definitions for chai-things
// Project: https://github.com/chaijs/chai-things
// Definitions by: David Broder-Rodgers <https://github.com/DavidBR-SW/>
// Definitions: https://github.com/DavidBR-SW/DefinitelyTyped
/// <reference path="../chai/chai.d.ts" />
declare module Chai {
interface ArrayAssertion {
include: ArrayInclude;
contain: ArrayInclude;
not: ArrayAssertion;
all: Assertion;
}
interface ArrayInclude {
(item: any): any;
a: Item;
an: Item;
one: Something;
some: Something;
something: Something;
any: Anything;
}
interface Anything extends Assertion {
(): any;
that: Assertion
with: Assertion
}
interface Something extends Assertion {
(): any;
that: Assertion
with: Assertion
}
interface Item {
item: Something;
thing: Something;
}
interface Deep {
equals: Equal;
}
}
interface Array<T> {
should: Chai.ArrayAssertion;
}
declare module "chai-things" {
function chaiThings(chai: any, utils: any): void;
export = chaiThings;
}