diff options
author | Vladislav Zarakovsky <vlad.zar@gmail.com> | 2015-12-05 17:47:52 +0300 |
---|---|---|
committer | Vladislav Zarakovsky <vlad.zar@gmail.com> | 2015-12-05 17:47:52 +0300 |
commit | f9d6cca542c66aef3c550e65cef3940393dab88e (patch) | |
tree | d727f656ad843bc67a3b0de83085d4862ad2dd0a /test | |
parent | 17934ef496e8dc2e7c35e536b31184dba94e5d6b (diff) | |
download | awesomplete-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.js | 37 |
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); }); }); }); |