Fix unit tests
This commit is contained in:
parent
f99fcd5dd6
commit
49031e0744
|
@ -129,7 +129,7 @@
|
||||||
$loading.addClass('hidden');
|
$loading.addClass('hidden');
|
||||||
$loading.removeClass('inlineblock');
|
$loading.removeClass('inlineblock');
|
||||||
if (result.ocs.meta.statuscode == 100) {
|
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 groups = result.ocs.data.exact.groups.concat(result.ocs.data.groups);
|
||||||
var remotes = result.ocs.data.exact.remotes.concat(result.ocs.data.remotes);
|
var remotes = result.ocs.data.exact.remotes.concat(result.ocs.data.remotes);
|
||||||
|
|
||||||
|
@ -195,8 +195,12 @@
|
||||||
|
|
||||||
var suggestions = users.concat(groups).concat(remotes);
|
var suggestions = users.concat(groups).concat(remotes);
|
||||||
|
|
||||||
$('.shareWithField').autocomplete("option", "autoFocus", true);
|
if (suggestions.length > 0) {
|
||||||
response(suggestions);
|
$('.shareWithField').autocomplete("option", "autoFocus", true);
|
||||||
|
response(suggestions);
|
||||||
|
} else {
|
||||||
|
response();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
response();
|
response();
|
||||||
}
|
}
|
||||||
|
|
|
@ -724,15 +724,30 @@ describe('OC.Share.ShareDialogView', function() {
|
||||||
var response = sinon.stub();
|
var response = sinon.stub();
|
||||||
dialog.autocompleteHandler({term: 'bob'}, response);
|
dialog.autocompleteHandler({term: 'bob'}, response);
|
||||||
var jsonData = JSON.stringify({
|
var jsonData = JSON.stringify({
|
||||||
"data": [{"label": "bob", "value": {"shareType": 0, "shareWith": "test"}}],
|
'ocs' : {
|
||||||
"status": "success"
|
'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(
|
fakeServer.requests[0].respond(
|
||||||
200,
|
200,
|
||||||
{'Content-Type': 'application/json'},
|
{'Content-Type': 'application/json'},
|
||||||
jsonData
|
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);
|
expect(autocompleteStub.calledWith("option", "autoFocus", true)).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -740,7 +755,14 @@ describe('OC.Share.ShareDialogView', function() {
|
||||||
dialog.render();
|
dialog.render();
|
||||||
var response = sinon.stub();
|
var response = sinon.stub();
|
||||||
dialog.autocompleteHandler({term: 'bob'}, response);
|
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(
|
fakeServer.requests[0].respond(
|
||||||
200,
|
200,
|
||||||
{'Content-Type': 'application/json'},
|
{'Content-Type': 'application/json'},
|
||||||
|
|
Loading…
Reference in New Issue