From dc966c9ebc2b85c5481a771fadeaaca427b0fd9d Mon Sep 17 00:00:00 2001
From: TxHawks <tofu.hawks@gmail.com>
Date: Sat, 2 Jan 2016 17:38:34 +0200
Subject: [PATCH] Fix tests to add an event to select()

---
 test/api/selectSpec.js    | 15 ++++++++-------
 test/awesompleteShared.js |  4 +++-
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/test/api/selectSpec.js b/test/api/selectSpec.js
index 82b40698..90a461ca 100644
--- a/test/api/selectSpec.js
+++ b/test/api/selectSpec.js
@@ -9,6 +9,7 @@ describe("awesomplete.select", function () {
 	def("firstIndex", function () { return 0 });
 	def("lastIndex", function () { return this.subject.ul.children.length - 1 });
 	def("lastLi", function () { return this.subject.ul.children[this.lastIndex] });
+	def("mockEvt", function () { return { 'originalTarget': this.lastLi } });
 
 	beforeEach(function () {
 		$.type(this.subject.input, "ite");
@@ -43,7 +44,7 @@ describe("awesomplete.select", function () {
 	function itSelects(expectedTxt) {
 		it("fires awesomplete-select event", function () {
 			var handler = $.spyOnEvent(this.subject.input, "awesomplete-select");
-			this.subject.select(this.selectArgument);
+			this.subject.select(this.selectArgument, this.mockEvt);
 
 			expect(handler).toHaveBeenCalledWith(jasmine.objectContaining({ text: expectedTxt }));
 		});
@@ -54,20 +55,20 @@ describe("awesomplete.select", function () {
 			});
 
 			it("changes the input value", function () {
-				this.subject.select(this.selectArgument);
+				this.subject.select(this.selectArgument, this.mockEvt);
 				expect(this.subject.input.value).toBe(expectedTxt);
 			});
 
 			it("closes completer", function () {
 				spyOn(this.subject, "close");
-				this.subject.select(this.selectArgument);
+				this.subject.select(this.selectArgument, this.mockEvt);
 
 				expect(this.subject.close).toHaveBeenCalled();
 			});
 
 			it("fires awesomplete-selectcomplete event", function () {
 				var handler = $.spyOnEvent(this.subject.input, "awesomplete-selectcomplete");
-				this.subject.select(this.selectArgument);
+				this.subject.select(this.selectArgument, this.mockEvt);
 
 				expect(handler).toHaveBeenCalled();
 			});
@@ -79,20 +80,20 @@ describe("awesomplete.select", function () {
 			});
 
 			it("does not change the input value", function () {
-				this.subject.select(this.selectArgument);
+				this.subject.select(this.selectArgument, this.mockEvt);
 				expect(this.subject.input.value).toBe("ite");
 			});
 
 			it("does not close completer", function () {
 				spyOn(this.subject, "close");
-				this.subject.select(this.selectArgument);
+				this.subject.select(this.selectArgument, this.mockEvt);
 
 				expect(this.subject.close).not.toHaveBeenCalled();
 			});
 
 			it("does not fire awesomplete-selectcomplete event", function () {
 				var handler = $.spyOnEvent(this.subject.input, "awesomplete-selectcomplete");
-				this.subject.select(this.selectArgument);
+				this.subject.select(this.selectArgument, this.mockEvt);
 
 				expect(handler).not.toHaveBeenCalled();
 			});
diff --git a/test/awesompleteShared.js b/test/awesompleteShared.js
index 64d53f43..78663324 100644
--- a/test/awesompleteShared.js
+++ b/test/awesompleteShared.js
@@ -24,10 +24,12 @@ var shared = {
   expectSelectingFirstSuggestionToWorkWith: function(val){
     return function(){
 			var li;
+      var evt;
 			shared.awesompleter.input.value = val;
 			shared.awesompleter.evaluate();
 			li = shared.awesompleter.ul.children[0];
-			shared.awesompleter.select(li);
+      evt = {originalTarget: li};
+			shared.awesompleter.select(li, evt);
 			expect(shared.awesompleter.input.value).toBe(li.textContent);
 		}
   },