summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVladislav Zarakovsky <vlad.zar@gmail.com>2015-12-05 17:47:52 +0300
committerVladislav Zarakovsky <vlad.zar@gmail.com>2015-12-05 17:47:52 +0300
commitf9d6cca542c66aef3c550e65cef3940393dab88e (patch)
treed727f656ad843bc67a3b0de83085d4862ad2dd0a /test
parent17934ef496e8dc2e7c35e536b31184dba94e5d6b (diff)
downloadawesomplete-f9d6cca542c66aef3c550e65cef3940393dab88e.zip
awesomplete-f9d6cca542c66aef3c550e65cef3940393dab88e.tar.gz
awesomplete-f9d6cca542c66aef3c550e65cef3940393dab88e.tar.bz2
Tests for merged #16791 Don't select items on mouse right-click
Diffstat (limited to 'test')
-rw-r--r--test/events/mousedownSpec.js37
1 files changed, 24 insertions, 13 deletions
diff --git a/test/events/mousedownSpec.js b/test/events/mousedownSpec.js
index 0e9ea51..5de338e 100644
--- a/test/events/mousedownSpec.js
+++ b/test/events/mousedownSpec.js
@@ -11,34 +11,45 @@ describe("mousedown event", function () {
this.subject.open();
$.type(this.subject.input, "ite");
this.subject.next();
+
+ spyOn(this.subject, "select");
});
+ def("li", function () { return this.subject.ul.children[1] });
+
describe("with ul target", function () {
- it("does not select item", function () {
- spyOn(this.subject, "select");
- $.fire(this.subject.ul, "mousedown");
+ def("target", function () { return this.subject.ul });
+ it("does not select item", function () {
+ $.fire(this.target, "mousedown", { button: 0 });
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");
+ def("target", function () { return this.li });
- expect(this.subject.select).toHaveBeenCalledWith(li);
+ describe("on left click", function () {
+ it("selects item", function () {
+ $.fire(this.target, "mousedown", { button: 0 });
+ expect(this.subject.select).toHaveBeenCalledWith(this.li);
+ });
+ });
+
+ describe("on right click", function () {
+ it("does not select item", function () {
+ $.fire(this.target, "mousedown", { button: 2 });
+ expect(this.subject.select).not.toHaveBeenCalled();
+ });
});
});
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");
+ def("target", function () { return $("mark", this.li) });
- expect(this.subject.select).toHaveBeenCalledWith(li);
+ it("selects item", function () {
+ $.fire(this.target, "mousedown", { button: 0 });
+ expect(this.subject.select).toHaveBeenCalledWith(this.li);
});
});
});