Commit b940b1b6 authored by Romain Courteaud's avatar Romain Courteaud

[linshare] Test get

parent 7f2660ff
......@@ -297,8 +297,6 @@
404
);
});
};
jIO.addStorage('linshare', LinshareStorage);
......
......@@ -349,6 +349,121 @@
});
});
/////////////////////////////////////////////////////////////////
// LinshareStorage.get
/////////////////////////////////////////////////////////////////
module("LinshareStorage.get", {
setup: function () {
this.server = sinon.fakeServer.create();
this.server.autoRespond = true;
this.server.autoRespondAfter = 5;
this.jio = jIO.createJIO({
type: "linshare",
url: domain
});
},
teardown: function () {
this.server.restore();
delete this.server;
}
});
test("get inexistent document", function () {
var search_url = domain + "/linshare/webservice/rest/user/v2/documents/",
search_result = JSON.stringify([
{
uuid: 'uuid1',
name: 'foo1',
modificationDate: '2',
}, {
uuid: 'uuid2',
name: 'foo2',
modificationDate: '1'
}
]);
this.server.respondWith("GET", search_url, [200, {
"Content-Type": "application/json"
}, search_result]);
stop();
expect(3);
this.jio.get('foo')
.fail(function (error) {
ok(error instanceof jIO.util.jIOError);
equal(error.message, "Can't find document with id : foo");
equal(error.status_code, 404);
})
.fail(function (error) {
ok(false, error);
})
.always(function () {
start();
});
});
test("get a document", function () {
var search_url = domain + "/linshare/webservice/rest/user/v2/documents/",
search_result = JSON.stringify([
{
uuid: 'uuid1',
name: 'foo1',
modificationDate: '2',
}, {
uuid: 'uuid2',
name: 'foo2',
modificationDate: '1',
}, {
uuid: 'uuid3',
name: 'foo',
modificationDate: '3',
metaData: JSON.stringify({
title: 'foouuid3'
})
}, {
uuid: 'uuid4',
name: 'foo',
modificationDate: '2',
}, {
uuid: 'uuid5',
name: 'foo',
modificationDate: '1',
}
]),
server = this.server;
this.server.respondWith("GET", search_url, [200, {
"Content-Type": "application/json"
}, search_result]);
stop();
expect(7);
this.jio.get('foo')
.then(function (result) {
deepEqual(result, {
title: 'foouuid3'
}, "Check document");
equal(server.requests.length, 1);
equal(server.requests[0].method, "GET");
equal(server.requests[0].url, search_url);
equal(server.requests[0].requestBody, undefined);
equal(server.requests[0].withCredentials, true);
deepEqual(server.requests[0].requestHeaders, {
"Accept": "application/json"
});
})
.fail(function (error) {
ok(false, error);
})
.always(function () {
start();
});
});
/////////////////////////////////////////////////////////////////
// DropboxStorage.put
/////////////////////////////////////////////////////////////////
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment