diff --git a/chai/chai-tests.ts b/chai/chai-tests.ts new file mode 100644 index 000000000..ab26aadbc --- /dev/null +++ b/chai/chai-tests.ts @@ -0,0 +1,90 @@ +/// + +var expect = chai.expect; + +function test_be() { + expect(true).to.be.ok; + expect(true).to.be.true; + expect(false).to.be.false; + expect(null).to.be.null; + expect(undefined).to.be.undefined; + expect([]).to.be.empty; + expect([]).to.be.arguments; + expect({}).to.be.an('object'); + expect({}).to.be.an.instanceof(Object); + expect(5).to.be.at.least(5); + expect(5).to.be.at.gte(5); + expect(5).to.be.at.most(5); + expect(5).to.be.at.lte(5); + expect('').to.be.a('string'); + expect(5).to.be.within(1, 6); + expect(5.001).to.be.closeTo(5, 0.5); +} + +function test_not() { + expect(5).to.not.be.a('string'); +} + +function test_deep() { + expect(5).to.deep.equal(5); + expect({ foo: 'bar' }).to.deep.property('foo', 'bar'); +} + +function test_have() { + expect({ foo: 'bar' }).to.have.property('foo', 'bar'); + expect([]).to.have.length(5); + expect({ foo: 'bar' }).to.have.ownProperty('foo'); + expect('foo-bar').to.have.string('bar'); + expect({ foo: 'bar', baz: 'qux' }).to.have.keys('foo', 'baz'); +} + +function test_exist() { + var obj = { foo: 'bar' }; + expect(obj.foo).to.exist; +} + +function test_equal() { + expect(5).to.equal(5); +} + +function test_include() { + expect('foo-bar').to.include('o-b'); + expect([1,2,3]).to.include(2); + expect({ foo: 'bar', baz: 'qux' }).to.include.keys('foo', 'baz'); + + expect('foo-bar').to.contain('o-b'); + expect([1,2,3]).to.contain(2); + expect({ foo: 'bar', baz: 'qux' }).to.contain.keys('foo', 'baz'); +} + +function test_throw() { + var foo = { + bar: () => { } + }; + + expect(foo.bar).to.throw(new Error); + expect(foo.bar).to.throw('An error'); + expect(foo.bar).to.throw(/error/); +} + +function test_eql() { + var foo = {} + expect(foo).to.eql({}); + expect(foo).to.eqls({}); +} + +function test_match() { + expect('foo-bar').to.match(/foo/); +} + +function test_respondTo() { + var foo = { + bar: () => { } + }; + + expect(foo).to.respondTo('bar'); +} + +function test_satisfy() { + expect(1).to.satisfy((n) => n > 0); +} \ No newline at end of file diff --git a/chai/chai.expect.d.ts b/chai/chai.d.ts similarity index 92% rename from chai/chai.expect.d.ts rename to chai/chai.d.ts index eccb443c4..df9e12382 100644 --- a/chai/chai.expect.d.ts +++ b/chai/chai.d.ts @@ -1,4 +1,9 @@ -declare module chai { +// Type definitions for chai 1.5.0 +// Project: http://chaijs.com/ +// Definitions by: Kazi Manzur Rashid +// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped + +declare module chai { interface Equality { (expected: any, message?: string): bool; } diff --git a/sinon-chai/sinon-chai-test.ts b/sinon-chai/sinon-chai-tests.ts similarity index 91% rename from sinon-chai/sinon-chai-test.ts rename to sinon-chai/sinon-chai-tests.ts index ef4b4b784..1ada034de 100644 --- a/sinon-chai/sinon-chai-test.ts +++ b/sinon-chai/sinon-chai-tests.ts @@ -1,5 +1,5 @@ -///  -///  +///  +///  var expect = chai.expect; diff --git a/sinon-chai/sinon-chai.d.ts b/sinon-chai/sinon-chai.d.ts index 00a9dc6f7..93e264ac2 100644 --- a/sinon-chai/sinon-chai.d.ts +++ b/sinon-chai/sinon-chai.d.ts @@ -3,7 +3,7 @@ // Definitions by: Kazi Manzur Rashid // DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped -///  +/// declare module chai { interface Been {