From 1cbc49538e2af1d32e199ebb0fc7fff6033e088a Mon Sep 17 00:00:00 2001 From: Theodore Brown Date: Sun, 25 Aug 2013 19:57:49 -0500 Subject: [PATCH] Fix chai-jquery tests --- chai-jquery/chai-jquery-tests.ts | 23 +++++++++++++++++++++++ chai/chai.d.ts | 20 +++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/chai-jquery/chai-jquery-tests.ts b/chai-jquery/chai-jquery-tests.ts index 97ed7a36a7..45c9981f5f 100644 --- a/chai-jquery/chai-jquery-tests.ts +++ b/chai-jquery/chai-jquery-tests.ts @@ -1,6 +1,8 @@ /// /// +// 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'); } \ No newline at end of file diff --git a/chai/chai.d.ts b/chai/chai.d.ts index 070765e00d..9d649a17c5 100644 --- a/chai/chai.d.ts +++ b/chai/chai.d.ts @@ -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;