Fix chai-jquery tests

This commit is contained in:
Theodore Brown
2013-08-25 19:57:49 -05:00
parent ee3a79f58f
commit 1cbc49538e
2 changed files with 42 additions and 1 deletions

View File

@@ -1,6 +1,8 @@
/// <reference path="../chai/chai.d.ts" />
/// <reference path="chai-jquery.d.ts" />
// tests taken from https://github.com/chaijs/chai-jquery
declare var $;
var expect = chai.expect;
@@ -17,6 +19,7 @@ function test_css() {
function test_data() {
expect($('#foo')).to.have.data('toggle');
expect($('#foo')).to.have.css('toggle', 'true');
expect($('body')).to.have.css('font-family').match(/sans-serif/);
}
function test_class() {
@@ -59,10 +62,30 @@ function test_disabled() {
expect($('#foo')).to.be.disabled;
}
function test_empty() {
$('.empty').should.be.empty;
expect($('body')).not.to.be.empty;
}
function test_exist() {
$('#exists').should.exist;
expect($('#nonexistent')).not.to.exist;
}
function test_match_selector() {
$('input').should.match('#foo');
}
function test_contain() {
$('body').should.contain('text');
expect($('#content')).to.contain('text');
}
function test_be_selector() {
expect($('#foo')).to.be(':empty');
}
function test_have_selector() {
$('body').should.have('h1');
expect($('#foo')).to.have('div');
}

20
chai/chai.d.ts vendored
View File

@@ -12,7 +12,25 @@ declare module chai {
(target: any): Expect;
}
interface Expect extends LanguageChains, NumericComparison, TypeComparison {
interface Assertions {
attr(name, value?);
css(name, value?);
data(name, value?);
class(className);
id(id);
html(html);
text(text);
value(value);
visible;
hidden;
selected;
checked;
disabled;
empty;
exist;
}
interface Expect extends LanguageChains, NumericComparison, TypeComparison, Assertions {
not: Expect;
deep: Deep;
a: TypeComparison;