2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-22 21:05:12 +00:00

Add parameter name test.

This commit is contained in:
Tomas Kirda 2013-01-20 18:51:44 -06:00
parent e2309c1533
commit a10c00c3ec

View File

@ -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');
});
});
});