diff options
-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); }); }); }); |