mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 04:49:15 +08:00
Add typings for chai-dom
This commit is contained in:
27
chai-dom/chai-dom-tests.ts
Normal file
27
chai-dom/chai-dom-tests.ts
Normal 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
38
chai-dom/chai-dom.d.ts
vendored
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user