diff options
author | Lea Verou <lea@verou.me> | 2015-12-27 23:24:10 +0200 |
---|---|---|
committer | Lea Verou <lea@verou.me> | 2015-12-27 23:24:10 +0200 |
commit | 9af4a6ef0b18901f893b116003271e4b718903f9 (patch) | |
tree | d727f656ad843bc67a3b0de83085d4862ad2dd0a /test/helpers/doubleDollarSpec.js | |
parent | 2dae7fd9d23752abff4f230c060b4d625bb77031 (diff) | |
parent | f9d6cca542c66aef3c550e65cef3940393dab88e (diff) | |
download | awesomplete-9af4a6ef0b18901f893b116003271e4b718903f9.zip awesomplete-9af4a6ef0b18901f893b116003271e4b718903f9.tar.gz awesomplete-9af4a6ef0b18901f893b116003271e4b718903f9.tar.bz2 |
Merge pull request #16785 from vlazar/features/improve-test-coverage
Improve test coverage
Diffstat (limited to 'test/helpers/doubleDollarSpec.js')
-rw-r--r-- | test/helpers/doubleDollarSpec.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/helpers/doubleDollarSpec.js b/test/helpers/doubleDollarSpec.js new file mode 100644 index 0000000..c76a10d --- /dev/null +++ b/test/helpers/doubleDollarSpec.js @@ -0,0 +1,49 @@ +describe("Awesomplete.$$", function () { + + $.fixture("options"); + + subject(function () { return Awesomplete.$$(this.expression, this.context) }); + + describe("with default context", itFindsAllElements); + + describe("with custom context", function () { + def("context", function () { return fixture.el }); + + itFindsAllElements(); + }); + + // Shared behaviors + + function itFindsAllElements() { + it("returns an array of DOM elements", function () { + this.expression = "#no-options"; + expect(this.subject).toEqual(jasmine.any(Array)); + expect(this.subject[0] instanceof HTMLElement).toBe(true); + }); + + it("finds all elements", function () { + this.expression = "input"; + expect(this.subject.length).toEqual($$("input").length); + }); + + it("finds DOM element", function () { + this.expression = "#no-options"; + expect(this.subject[0] instanceof HTMLElement).toBe(true); + }); + + it("finds by id", function () { + this.expression = "#no-options"; + expect(this.subject[0].id).toEqual("no-options"); + }); + + it("finds by class name", function () { + this.expression = ".simple-input"; + expect(this.subject[0].id).toEqual("no-options"); + }); + + it("finds by tag name", function () { + this.expression = "datalist"; + expect(this.subject[0].id).toEqual("list"); + }); + } +}); |