Set error expected by the DAV client for a failed move

A revert triggers a move in the DAV client, and the DAV client expects a
DAV error message to be provided by the server in case of failure; if
no error message is given the client ends trying to get an attribute
from an undefined object and "crashes".

Besides that, if the revert fails the "done" callback of the promise
(the first parameter of "then") is never called, so a "fail" callback
should be used instead.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2018-10-25 13:07:06 +02:00
parent 24abfd8869
commit 661756b02a
1 changed files with 10 additions and 2 deletions

View File

@ -86,9 +86,17 @@ describe('OCA.Versions.VersionModel', function() {
});
expect(fakeServer.requests.length).toEqual(1);
fakeServer.requests[0].respond(404);
var responseErrorHeaders = {
"Content-Type": "application/xml"
};
var responseErrorBody =
'<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">' +
' <s:exception>Sabre\\DAV\\Exception\\SomeException</s:exception>' +
' <s:message>Some error message</s:message>' +
'</d:error>';
fakeServer.requests[0].respond(404, responseErrorHeaders, responseErrorBody);
promise.then(function() {
promise.fail(function() {
expect(revertEventStub.notCalled).toEqual(true);
expect(successStub.notCalled).toEqual(true);
expect(errorStub.calledOnce).toEqual(true);