1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
describe("awesomplete.open", function () {
$.fixture("plain");
subject(function () { return new Awesomplete("#plain", this.options) });
it("opens completer", function () {
this.subject.open();
expect(this.subject.ul.hasAttribute("hidden")).toBe(false);
});
// Exposes this bug https://github.com/LeaVerou/awesomplete/pull/16740
// FIXME better fix is probably required as discussed in PR above
xit("fills in the list on creation", function () {
$("#plain").value = "ite";
this.options = { list: "item1, item2" };
this.subject.open();
expect(this.subject.ul.children.length).toBe(2);
});
it("fires awesomplete-open event", function () {
var handler = $.spyOnEvent(this.subject.input, "awesomplete-open");
this.subject.open();
expect(handler).toHaveBeenCalled();
});
describe("with autoFirst: true", function () {
def("options", function () { return { autoFirst: true } });
it("automatically selects first item", function () {
spyOn(this.subject, "goto");
this.subject.open();
expect(this.subject.goto).toHaveBeenCalledWith(0);
});
});
describe("with autoFirst: false", function () {
def("options", function () { return { autoFirst: false } });
it("does not select any item", function () {
this.subject.open();
expect(this.subject.selected).toBe(false);
expect(this.subject.index).toBe(-1);
});
});
});
|