Skip to content

Commit 0a8cde5

Browse files
committed
beginning specs of valueKey
1 parent b445ec6 commit 0a8cde5

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

spec/autocompleteBehavior.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,4 +690,40 @@ describe('Autocomplete', function () {
690690
expect(instance.suggestions.length).toBe(4);
691691
});
692692
});
693+
694+
it('Should accept valueKey as an aoption', function () {
695+
var input = $('<input />'),
696+
instance,
697+
ajaxExecuted,
698+
serviceUrl = "/items.json";
699+
700+
input.autocomplete({
701+
serviceUrl: serviceUrl,
702+
keyPath: "items",
703+
valueKey: "nombre"
704+
});
705+
706+
$.mockjax({
707+
url: serviceUrl,
708+
responseTime: 5,
709+
response: function (settings) {
710+
ajaxExecuted = true;
711+
var response = {
712+
items: [{nombre: "Item 1", id: 1}, {nombre: "Item 2", id: 2}, {nombre: "Item 3", id: 3}]
713+
};
714+
this.responseText = JSON.stringify(response);
715+
}
716+
});
717+
718+
input.val("item");
719+
instance = input.autocomplete();
720+
instance.onValueChange();
721+
722+
waits(10);
723+
724+
runs(function () {
725+
expect(ajaxExecuted).toBeTruthy();
726+
expect(instance.suggestions.length).toBe(3);
727+
});
728+
})
693729
});

0 commit comments

Comments
 (0)