From 0bcf347382b57dd0abc423f3aca8f36f6a32173c Mon Sep 17 00:00:00 2001 From: Craig Brett Date: Mon, 23 Dec 2013 14:49:15 +0000 Subject: [PATCH 1/2] Initial commit... added file and empty tsparams file --- jasmine-fixture/jasmine-fixture.d.ts | 16 ++++++++++++++++ jasmine-fixture/jasmine-fixture.d.ts.tscparams | 1 + 2 files changed, 17 insertions(+) create mode 100644 jasmine-fixture/jasmine-fixture.d.ts create mode 100644 jasmine-fixture/jasmine-fixture.d.ts.tscparams diff --git a/jasmine-fixture/jasmine-fixture.d.ts b/jasmine-fixture/jasmine-fixture.d.ts new file mode 100644 index 000000000..4c11fe94f --- /dev/null +++ b/jasmine-fixture/jasmine-fixture.d.ts @@ -0,0 +1,16 @@ +// Type definitions for Jasmine-fixture 1.0.7 +// Project: https://github.com/searls/jasmine-fixture +// Definitions by: Craig Brett +// 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; +} \ No newline at end of file diff --git a/jasmine-fixture/jasmine-fixture.d.ts.tscparams b/jasmine-fixture/jasmine-fixture.d.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jasmine-fixture/jasmine-fixture.d.ts.tscparams @@ -0,0 +1 @@ +"" From b0f4bf335ba6465e7acf5fd766a074205bb14240 Mon Sep 17 00:00:00 2001 From: Craig Brett Date: Tue, 24 Dec 2013 08:59:14 +0000 Subject: [PATCH 2/2] First crack at tests to test/show jasmine-fixture in action --- jasmine-fixture/jasmine-fixture-tests.ts | 48 +++++++++++++++++++ .../jasmine-fixture-tests.ts.tscparams | 1 + 2 files changed, 49 insertions(+) create mode 100644 jasmine-fixture/jasmine-fixture-tests.ts create mode 100644 jasmine-fixture/jasmine-fixture-tests.ts.tscparams diff --git a/jasmine-fixture/jasmine-fixture-tests.ts b/jasmine-fixture/jasmine-fixture-tests.ts new file mode 100644 index 000000000..1246aafbd --- /dev/null +++ b/jasmine-fixture/jasmine-fixture-tests.ts @@ -0,0 +1,48 @@ +/// +/// +/// +/// + +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(); + }); + }); +}); \ No newline at end of file diff --git a/jasmine-fixture/jasmine-fixture-tests.ts.tscparams b/jasmine-fixture/jasmine-fixture-tests.ts.tscparams new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/jasmine-fixture/jasmine-fixture-tests.ts.tscparams @@ -0,0 +1 @@ +""