1
0
mirror of https://github.com/chubin/cheat.sh.git synced 2026-06-20 13:16:44 +02:00
Files
cheat.sh/share/static/awesomplete-gh-pages/test/helpers/doubleDollarSpec.js
T
2017-05-08 21:17:29 +00:00

50 lines
1.3 KiB
JavaScript

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");
});
}
});