blob: ae1bea00a3aafd897334d231854c991c4ed10f1b (
plain)
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
|
describe("awesomplete.close", function () {
$.fixture("plain");
subject(function () { return new Awesomplete("#plain", { list: ["item1", "item2", "item3"] }) });
beforeEach(function () {
$.type(this.subject.input, "ite");
this.subject.open();
this.subject.next();
});
it("closes completer", function () {
this.subject.close();
expect(this.subject.ul.hasAttribute("hidden")).toBe(true);
});
it("makes no item selected", function () {
this.subject.close();
expect(this.subject.index).toBe(-1);
});
it("fires awesomplete-close event", function () {
var handler = $.spyOnEvent(this.subject.input, "awesomplete-close");
this.subject.close();
expect(handler).toHaveBeenCalledWith(
jasmine.any(document.createEvent("HTMLEvents").constructor)
);
});
it("returns early if already closed", function () {
var handler = $.spyOnEvent(this.subject.input, "awesomplete-close");
this.subject.close();
this.subject.close();
expect(handler.calls.count()).toBe(1);
});
});
|