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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
describe("Awesomplete list", function () {
$.fixture("options");
subject(function () { return new Awesomplete(this.element, this.options) });
def("element", "#no-options");
it("is empty if not provided", function () {
expect(this.subject._list).toEqual([]);
});
describe("setter", function () {
it("assigns from array", function () {
this.subject.list = [ "From", "Array" ];
expect(this.subject._list).toEqual([ "From", "Array" ]);
});
it("assigns from comma separated list", function () {
this.subject.list = "From,Inline,List";
expect(this.subject._list).toEqual([ "From", "Inline", "List" ]);
});
it("assigns from element specified by selector", function () {
this.subject.list = "#data-list";
expect(this.subject._list).toEqual([ "With", "Data", "List" ]);
});
it("assigns from element", function () {
this.subject.list = $("#data-list");
expect(this.subject._list).toEqual([ "With", "Data", "List" ]);
});
it("does not assigns from not found list", function () {
this.subject.list = "#nosuchlist";
expect(this.subject._list).toEqual([]);
});
it("does not assigns from empty list", function () {
this.subject.list = "#empty-list";
expect(this.subject._list).toEqual([]);
});
describe("with active input", function() {
beforeEach(function() {
this.subject.input.focus();
});
it("evaluates completer", function() {
spyOn(this.subject, "evaluate");
this.subject.list = "#data-list";
expect(this.subject.evaluate).toHaveBeenCalled();
});
});
});
describe("constructor option", function () {
it("assigns from array", function () {
this.options = { list: [ "From", "Array" ] };
expect(this.subject._list).toEqual([ "From", "Array" ]);
});
it("assigns from comma separated list", function () {
this.options = { list: "From,Inline,List" };
expect(this.subject._list).toEqual([ "From", "Inline", "List" ]);
});
it("assigns from element specified by selector", function () {
this.options = { list: "#data-list" };
expect(this.subject._list).toEqual([ "With", "Data", "List" ]);
});
it("assigns from list specified by element", function () {
this.options = { list: $("#data-list") };
expect(this.subject._list).toEqual([ "With", "Data", "List" ]);
});
});
describe("data-list html attribute", function () {
it("assigns from comma separated list", function () {
this.element = "#with-data-list-inline";
expect(this.subject._list).toEqual(["With", "Data", "List", "Inline"]);
});
it("assigns from element referenced by selector", function () {
this.element = "#with-data-list";
expect(this.subject._list).toEqual(["With", "Data", "List"]);
});
});
describe("list html attribute", function () {
it("assigns from element referenced by id", function () {
this.element = "#with-list";
expect(this.subject._list).toEqual(["With", "List"]);
});
});
});
|