From 6e1e76882a438a1ba0dec0add68e8cb9a78fff00 Mon Sep 17 00:00:00 2001 From: Matt Lewis Date: Sat, 2 Jul 2016 15:15:23 +0100 Subject: [PATCH] Add typings for chai-dom --- chai-dom/chai-dom-tests.ts | 27 +++++++++++++++++++++++++++ chai-dom/chai-dom.d.ts | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 chai-dom/chai-dom-tests.ts create mode 100644 chai-dom/chai-dom.d.ts diff --git a/chai-dom/chai-dom-tests.ts b/chai-dom/chai-dom-tests.ts new file mode 100644 index 0000000000..2fca54765e --- /dev/null +++ b/chai-dom/chai-dom-tests.ts @@ -0,0 +1,27 @@ +/// + +import * as chai from 'chai'; +import * as chaiDom from 'chai-dom'; + +chai.use(chaiDom); +var expect = chai.expect; + +function test() { + + var testElement = '
'; + expect(testElement).to.have.attribute('foo', 'bar'); + expect(testElement).to.have.attr('foo').match(/bar/); + expect(testElement).to.have.class('foo'); + expect(testElement).to.have.id('id'); + expect(testElement).to.have.html('foo'); + expect(testElement).to.have.text('foo'); + expect(testElement).to.have.text(['foo', 'bar']); + expect(testElement).to.have.value('foo'); + expect(testElement).to.be.empty; + expect(testElement).to.have.length(2); + expect(testElement).to.exist; + expect(testElement).to.match('foo'); + expect(testElement).to.contain('foo'); + expect(testElement).to.contain(document.body); + +} \ No newline at end of file diff --git a/chai-dom/chai-dom.d.ts b/chai-dom/chai-dom.d.ts new file mode 100644 index 0000000000..397bc17cb4 --- /dev/null +++ b/chai-dom/chai-dom.d.ts @@ -0,0 +1,38 @@ +// Type definitions for chai-dom +// Project: https://github.com/nathanboktae/chai-dom +// Definitions by: Matt Lewis +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace Chai { + + interface Assertion { + + attr(name: string, value?: string): Assertion; + + attribute(name: string, value?: string): Assertion; + + class(className: string): Assertion; + + id(id: string): Assertion; + + html(html: string): Assertion; + + text(text: string|string[]): Assertion; + + value(text: string): Assertion; + + } + +} + +declare module "chai-dom" { + + function chaiDom(chai: any, utils: any): void; + + namespace chaiDom { + } + + export = chaiDom; +}