Add typings for chai-dom

This commit is contained in:
Matt Lewis
2016-07-02 15:15:23 +01:00
parent 33585c55fb
commit 6e1e76882a
2 changed files with 65 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
/// <reference path="chai-dom.d.ts" />
import * as chai from 'chai';
import * as chaiDom from 'chai-dom';
chai.use(chaiDom);
var expect = chai.expect;
function test() {
var testElement = '<div></div>';
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);
}

38
chai-dom/chai-dom.d.ts vendored Normal file
View File

@@ -0,0 +1,38 @@
// Type definitions for chai-dom
// Project: https://github.com/nathanboktae/chai-dom
// Definitions by: Matt Lewis <https://github.com/mattlewis92>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../chai/chai.d.ts" />
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;
}