$loading.addClass('hidden');
$loading.removeClass('inlineblock');
if (result.ocs.meta.statuscode == 100) {
- var users = [].concat(result.ocs.data.exact.users).concat(result.ocs.data.users);
+ var users = result.ocs.data.exact.users.concat(result.ocs.data.users);
var groups = result.ocs.data.exact.groups.concat(result.ocs.data.groups);
var remotes = result.ocs.data.exact.remotes.concat(result.ocs.data.remotes);
var suggestions = users.concat(groups).concat(remotes);
- $('.shareWithField').autocomplete("option", "autoFocus", true);
- response(suggestions);
+ if (suggestions.length > 0) {
+ $('.shareWithField').autocomplete("option", "autoFocus", true);
+ response(suggestions);
+ } else {
+ response();
+ }
} else {
response();
}
var response = sinon.stub();
dialog.autocompleteHandler({term: 'bob'}, response);
var jsonData = JSON.stringify({
- "data": [{"label": "bob", "value": {"shareType": 0, "shareWith": "test"}}],
- "status": "success"
+ 'ocs' : {
+ 'meta' : {
+ 'status' : 'success',
+ 'statuscode' : 100,
+ 'message' : null
+ },
+ 'data' : {
+ 'exact' : {
+ 'users' : [],
+ 'groups' : [],
+ 'remotes': []
+ },
+ 'users' : [{'label': 'bob', 'value': {'shareType': 0, 'shareWith': 'test'}}],
+ 'groups' : [],
+ 'remotes': []
+ }
+ }
});
fakeServer.requests[0].respond(
200,
{'Content-Type': 'application/json'},
jsonData
);
- expect(response.calledWithExactly(JSON.parse(jsonData).data)).toEqual(true);
+ expect(response.calledWithExactly(JSON.parse(jsonData).ocs.data.users)).toEqual(true);
expect(autocompleteStub.calledWith("option", "autoFocus", true)).toEqual(true);
});
dialog.render();
var response = sinon.stub();
dialog.autocompleteHandler({term: 'bob'}, response);
- var jsonData = JSON.stringify({"status": "failure"});
+ var jsonData = JSON.stringify({
+ 'ocs' : {
+ 'meta' : {
+ 'status': 'failure',
+ 'statuscode': 400
+ }
+ }
+ });
fakeServer.requests[0].respond(
200,
{'Content-Type': 'application/json'},