Merge pull request #1469 from craigbrett17/master

jasmine-fixture definitely typed file
This commit is contained in:
Masahiro Wakame
2013-12-24 01:27:25 -08:00
4 changed files with 66 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
/// <reference path="../jasmine/jasmine.d.ts" />
/// <reference path="../jquery/jquery.d.ts" />
/// <reference path="../jasmine-jquery/jasmine-jquery.d.ts" />
/// <reference path="jasmine-fixture.d.ts" />
describe("Jasmine fixture extension", () => {
describe("Affixes dom elements to body", () => {
it("Inserts a new element on affix", () => {
expect('#test1').not.toExist();
affix('#test1');
expect('#test1').toExist();
});
it("Inserts subelements when given", () => {
affix('#test2 .something-special');
expect('.something-special').toExist();
var parent = $('#test2 .something-special').parent();
var id = parent.attr('id');
expect(id).toBe('test2');
});
it("Can add elements with multiple classes", () => {
affix('#test3 div.this.that');
expect('#test3 div').toHaveClass('this');
expect('#test3 div').toHaveClass('that');
});
it("Creates new elements as divs by default", () => {
affix('#test4 .subelement');
expect('#test4 .subelement').toBeMatchedBy('div');
});
it("Can add different types of elements", () => {
affix('#test5 p.part1');
expect('#test5 .part1').toBeMatchedBy('p');
affix('#test5 span.part2');
expect('#test5 .part2').toBeMatchedBy('span');
});
});
describe("Cleans up after each test", () => {
it("Formerly affixed parts are removed when out of scope", () => {
expect('#test1').not.toExist();
expect('#test2').not.toExist();
expect('#test3').not.toExist();
});
});
});
@@ -0,0 +1 @@
""
+16
View File
@@ -0,0 +1,16 @@
// Type definitions for Jasmine-fixture 1.0.7
// Project: https://github.com/searls/jasmine-fixture
// Definitions by: Craig Brett <https://github.com/craigbrett17/>
// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped
/** Affixes the given jquery selectors into the body and will be removed after each spec
* @param {string} selector The JQuery selector to be added to the dom
*/
declare function affix(selector: string): JQuery;
interface JQuery {
/** Affixes the given jquery selectors into the element and will be removed after each spec
* @param {string} selector The JQuery selector to be added to the dom
*/
affix(selector: string): JQuery;
}
@@ -0,0 +1 @@
""