Commit be4a9db1 authored by lucas.parsy's avatar lucas.parsy

refactored gdrivestorage.js

Improved gdrive allDocs test to check return value.
parent 352ee4fb
......@@ -10,7 +10,7 @@
/*global jIO, Blob, RSVP, UriTemplate, JSON*/
/*jslint nomen: true*/
(function (jIO, Blob, RSVP, UriTemplate) {
(function (jIO, Blob, RSVP, UriTemplate, JSON) {
"use strict";
var UPLOAD_URL = "https://www.googleapis.com{/upload}/drive/v2/files{/id}" +
......@@ -64,7 +64,7 @@
}
result.nextPageToken = obj.nextPageToken;
return result;
}, function (error) {handleError(error); });
}, handleError);
}
function checkName(name) {
......@@ -227,4 +227,4 @@
jIO.addStorage('gdrive', GdriveStorage);
}(jIO, Blob, RSVP, UriTemplate));
}(jIO, Blob, RSVP, UriTemplate, JSON));
......@@ -357,20 +357,58 @@
});
test("get all docs", function () {
var objectResult = {"data": {"rows": [], "total_rows": 6}},
server = this.server;
objectResult.data.rows.push(
{"id": "0B4kh3jbjOf5Lb2theE8xWHhvWXM", "title": "attach1",
"mimeType": "text/plain",
"parents": [{"id": "0B4kh3jbjOf5LN0Y2V0ZJS0VxS00", "isRoot": false}],
"value": {}}
);
objectResult.data.rows.push(
{"id": "0B4kh3jbjOf5LamRlX21MZlVCYXM", "title": "file2",
"mimeType": "text/plain",
"parents": [{"id": "0AIkh3jbjOf5LUk9PVA", "isRoot": true}], "value": {}}
);
objectResult.data.rows.push(
{"id": "0B4kh3jbjOf5LTVlUWVVROWlBZzg",
"title": "file1", "mimeType": "text/plain",
"parents": [{"id": "0AIkh3jbjOf5LUk9PVA", "isRoot": true}], "value": {}}
);
objectResult.data.rows.push(
{"id": "0B4kh3jbjOf5LYTRaaV9YUkJ4a0U",
"title": "folder2",
"mimeType": "application/vnd.google-apps.folder",
"parents": [{"id": "0AIkh3jbjOf5LUk9PVA", "isRoot": true}], "value": {}}
);
objectResult.data.rows.push(
{"id": "0B4kh3jbjOf5LN0Y2V0ZJS0VxS00",
"title": "folder1",
"mimeType": "application/vnd.google-apps.folder",
"parents": [{"id": "0AIkh3jbjOf5LUk9PVA", "isRoot": true}], "value": {}}
);
objectResult.data.rows.push(
{"id": "0B4kh3jbjOf5Lc3RhcnRlcl9maWxl",
"title": "How to get started with Drive",
"mimeType": "application/pdf",
"parents": [{"id": "0AIkh3jbjOf5LUk9PVA", "isRoot": true}], "value": {}}
);
this.server.respondWith("GET", listUrl, [200, {
}, sampleList]);
stop();
expect(6);
var server = this.server;
expect(7);
this.jio.allDocs()
.then(function () {
.then(function (res) {
equal(server.requests.length, 1);
equal(server.requests[0].method, "GET");
equal(server.requests[0].url, listUrl);
equal(server.requests[0].status, 200);
equal(server.requests[0].requestBody, undefined);
equal(server.requests[0].responseText, sampleList);
deepEqual(res, objectResult);
})
.fail(function (error) {
ok(false, error);
......
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