summaryrefslogtreecommitdiffstats
path: root/test/api/closeSpec.js
blob: b1de6bc7cdefaff24ee585b801428c9e9a9144e5 (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
describe("awesomplete.close", function () {

	$.fixture("plain");

	subject(function () { return new Awesomplete("#plain") });

	beforeEach(function () {
		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.selected).toBe(false);
		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();
	});
});