summaryrefslogtreecommitdiffstats
path: root/test/api/closeSpec.js
blob: e22fe2f30e0995d14539cd3fa77b22d954866869 (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
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).toHaveBeenCalled();
	});
});