From 44e02ee490999a4accd9cfddaf492acc034f84fa Mon Sep 17 00:00:00 2001 From: Kazi Manzur Rashid Date: Tue, 30 Apr 2013 13:47:47 +0600 Subject: [PATCH] Included chai-jquery definition --- chai-jquery/chai-jquery-tests.ts | 68 ++++++++++++++++++++++++++++++++ chai-jquery/chai-jquery.d.ts | 37 +++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 chai-jquery/chai-jquery-tests.ts create mode 100644 chai-jquery/chai-jquery.d.ts diff --git a/chai-jquery/chai-jquery-tests.ts b/chai-jquery/chai-jquery-tests.ts new file mode 100644 index 0000000000..fbd05480ec --- /dev/null +++ b/chai-jquery/chai-jquery-tests.ts @@ -0,0 +1,68 @@ +///  +///  + +declare var $; +var expect = chai.expect; + +function test_attr() { + expect($('#foo')).to.have.attr('id'); + expect($('#foo')).to.have.attr('class', 'container'); +} + +function test_css() { + expect($('#foo')).to.have.css('color'); + expect($('#foo')).to.have.css('font-family', 'serif'); +} + +function test_data() { + expect($('#foo')).to.have.data('toggle'); + expect($('#foo')).to.have.css('toggle', 'true'); +} + +function test_class() { + expect($('#foo')).to.have.class('container'); +} + +function test_id() { + expect($('#foo')).to.have.id('foo'); +} + +function test_html() { + expect($('#foo')).to.have.html('
bar
'); +} + +function test_text() { + expect($('#foo')).to.have.text('bar'); +} + +function test_value() { + expect($('#foo')).to.have.value('bar'); +} + +function test_visible() { + expect($('#foo')).to.be.visible; +} + +function test_hidden() { + expect($('#foo')).to.be.hidden; +} + +function test_selected() { + expect($('#foo')).to.be.selected; +} + +function test_checked() { + expect($('#foo')).to.be.checked; +} + +function test_disabled() { + expect($('#foo')).to.be.disabled; +} + +function test_be_selector() { + expect($('#foo')).to.be(':empty'); +} + +function test_have_selector() { + expect($('#foo')).to.have('div'); +} \ No newline at end of file diff --git a/chai-jquery/chai-jquery.d.ts b/chai-jquery/chai-jquery.d.ts new file mode 100644 index 0000000000..d038c76ff4 --- /dev/null +++ b/chai-jquery/chai-jquery.d.ts @@ -0,0 +1,37 @@ +// Type definitions for chai-jquery 1.1.1 +// Project: https://github.com/chaijs/chai-jquery +// Definitions by: Kazi Manzur Rashid +// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module chai { + interface NameValueRegexMatcher { + match(value: RegExp): bool; + } + + interface NameValueMatcher { + (name: string, value?: string): bool; + } + + interface Have { + attr: NameValueMatcher; + css: NameValueMatcher; + data: NameValueMatcher; + class(className: string): bool; + id(id: string): bool; + html(html: string): bool; + text(text: string): bool; + value(text: string): bool; + (selector: string): bool; + } + + interface Be { + visible: bool; + hidden: bool; + selected: bool; + checked: bool; + disabled: bool; + (selector: string): bool; + } +}