summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladislav Zarakovsky <vlad.zar@gmail.com>2015-11-24 14:18:35 +0300
committerVladislav Zarakovsky <vlad.zar@gmail.com>2015-11-24 15:43:55 +0300
commit94bb12f82be2ffa6c9adae153b8880cbbae77dfe (patch)
tree7ffab71b64068a928d569fa8fa5a9c584644ab89
parentc1c5e13f7f45e2264947890b5d81da234de2c937 (diff)
downloadawesomplete-94bb12f82be2ffa6c9adae153b8880cbbae77dfe.zip
awesomplete-94bb12f82be2ffa6c9adae153b8880cbbae77dfe.tar.gz
awesomplete-94bb12f82be2ffa6c9adae153b8880cbbae77dfe.tar.bz2
mousedown event tests
-rw-r--r--test/events/mousedownSpec.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/events/mousedownSpec.js b/test/events/mousedownSpec.js
new file mode 100644
index 0000000..c1dd20b
--- /dev/null
+++ b/test/events/mousedownSpec.js
@@ -0,0 +1,45 @@
+describe("mousedown event", function () {
+
+ $.fixture("plain");
+
+ subject(function () {
+ return new Awesomplete("#plain", { list: ["item1", "item2", "item3"] });
+ });
+
+ beforeEach(function () {
+ this.subject.input.focus();
+ this.subject.open();
+ $.type(this.subject.input, "ite");
+ this.subject.next();
+ });
+
+ describe("with ul target", function () {
+ it("does not select item", function () {
+ spyOn(this.subject, "select");
+ $.fire(this.subject.ul, "mousedown");
+
+ expect(this.subject.select).not.toHaveBeenCalled();
+ });
+ });
+
+ describe("with li target", function () {
+ it("selects item", function () {
+ var li = this.subject.ul.children[1];
+ spyOn(this.subject, "select");
+ $.fire(li, "mousedown");
+
+ expect(this.subject.select).toHaveBeenCalledWith(li);
+ });
+ });
+
+ describe("with child of li target", function () {
+
+ it("selects item", function () {
+ var li = this.subject.ul.children[1];
+ spyOn(this.subject, "select");
+ $.fire($("mark", li), "mousedown");
+
+ expect(this.subject.select).toHaveBeenCalledWith(li);
+ });
+ });
+});