Merge pull request #9932 from mattlewis92/master

Add typings for chai-dom
This commit is contained in:
Mohamed Hegazy
2016-07-03 16:53:52 -07:00
committed by GitHub
2 changed files with 65 additions and 0 deletions
+27
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
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;
}