summaryrefslogtreecommitdiffstats
path: root/test/api/openSpec.js
diff options
context:
space:
mode:
authorVladislav Zarakovsky <vlad.zar@gmail.com>2015-12-28 09:31:07 +0300
committerVladislav Zarakovsky <vlad.zar@gmail.com>2015-12-28 09:31:07 +0300
commit0b38bb595b9a4b8a6353fd4748dfb3c6530b57ac (patch)
treeeaea8096b6ffa7f04fb218f5e9fea7942edfb668 /test/api/openSpec.js
parent730f82a2bbe7aa3ac65f574e3ce1c481fd953f66 (diff)
parent5dbfd450fb5d5ce0c1b8886baed047f91d926691 (diff)
downloadawesomplete-0b38bb595b9a4b8a6353fd4748dfb3c6530b57ac.zip
awesomplete-0b38bb595b9a4b8a6353fd4748dfb3c6530b57ac.tar.gz
awesomplete-0b38bb595b9a4b8a6353fd4748dfb3c6530b57ac.tar.bz2
Merge remote-tracking branch 'upstream/gh-pages' into features/code-climate
Diffstat (limited to 'test/api/openSpec.js')
-rw-r--r--test/api/openSpec.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/api/openSpec.js b/test/api/openSpec.js
new file mode 100644
index 0000000..848b960
--- /dev/null
+++ b/test/api/openSpec.js
@@ -0,0 +1,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);
+ });
+ });
+});