diff --git a/spec/autocompleteBehavior.js b/spec/autocompleteBehavior.js index 9ab5ef6..325d353 100644 --- a/spec/autocompleteBehavior.js +++ b/spec/autocompleteBehavior.js @@ -1,5 +1,5 @@ /*jslint vars: true*/ -/*global describe, it, expect, waitsFor, runs, afterEach, spyOn, $*/ +/*global describe, it, expect, waits, waitsFor, runs, afterEach, spyOn, $*/ describe('Autocomplete', function () { 'use strict'; @@ -119,7 +119,6 @@ describe('Autocomplete', function () { query: query, suggestions: [] }; - ajaxExecuted = true; this.responseText = JSON.stringify(response); } }); @@ -216,4 +215,36 @@ describe('Autocomplete', function () { expect(autocomplete.selectedIndex).toBe(0); }); + + it('Should use custom query parameter name', function () { + var input = document.createElement('input'), + paramName = 'custom', + paramValue = null, + autocomplete = new $.Autocomplete(input, { + serviceUrl: '/test-query', + paramName: paramName + }); + + $.mockjax({ + url: '/test-query', + responseTime: 5, + response: function (settings) { + paramValue = settings.data[paramName]; + var response = { + query: paramValue, + suggestions: [] + }; + this.responseText = JSON.stringify(response); + } + }); + + input.value = 'Jam'; + autocomplete.onValueChange(); + + waits(10); + + runs(function () { + expect(paramValue).toBe('Jam'); + }); + }); }); \ No newline at end of file