Commit 4132676c authored by Romain Courteaud's avatar Romain Courteaud

FBStorage: do not embed a test inside another one

parent ac07621c
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// Facebook Storage constructor // Facebook Storage constructor
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
module("Facebook Drive Storage.constructor"); module("FacebookStorage.constructor");
test("create storage", function () { test("create storage", function () {
var jio = jIO.createJIO({ var jio = jIO.createJIO({
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Facebook Storage.get // Facebook Storage.get
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
module("Facebook Storage.get", { module("FacebookStorage.get", {
setup: function () { setup: function () {
this.server = sinon.fakeServer.create(); this.server = sinon.fakeServer.create();
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Facebook Storage.allDocs // Facebook Storage.allDocs
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
module("Facebook Storage.allDocs", { module("FacebookStorage.allDocs", {
setup: function () { setup: function () {
this.server = sinon.fakeServer.create(); this.server = sinon.fakeServer.create();
...@@ -544,73 +544,74 @@ ...@@ -544,73 +544,74 @@
.always(function () { .always(function () {
start(); start();
}); });
});
test("get all posts with limit", function () { test("get all posts with limit", function () {
var url1 = 'https://graph.facebook.com/v2.9/sample_user_id/feed?fields' + var url1 = 'https://graph.facebook.com/v2.9/sample_user_id/feed?fields' +
'=&limit=5&since=&access_token=' + '=&limit=5&since=&access_token=' +
'sample_token', 'sample_token',
url2 = 'https://graph.facebook.com/v2.9/sample_user_id/feed?fields' + url2 = 'https://graph.facebook.com/v2.9/sample_user_id/feed?fields' +
'=&limit=5&since=&access_token=' + '=&limit=5&since=&access_token=' +
'sample_token&__paging_token=sample_paging_token', 'sample_token&__paging_token=sample_paging_token',
body1 = '{"data": [{"created_time": "2016", "id": "1", ' + body1 = '{"data": [{"created_time": "2016", "id": "1", ' +
'"message": "Test 1"}, {"created_time": "2016", "id": "2", ' + '"message": "Test 1"}, {"created_time": "2016", "id": "2", ' +
'"message": "Test 2"}, {"created_time": "2016", "id": "3", ' + '"message": "Test 2"}, {"created_time": "2016", "id": "3", ' +
'"message": "Test 3"}, {"created_time": "2016", "id": "4", ' + '"message": "Test 3"}, {"created_time": "2016", "id": "4", ' +
'"message": "Test 4"}, {"created_time": "2016", "id": "5", ' + '"message": "Test 4"}, {"created_time": "2016", "id": "5", ' +
'"message": "Test 5"}, {"created_time": "2016", "id": "6", ' + '"message": "Test 5"}, {"created_time": "2016", "id": "6", ' +
'"message": "Test 6"}, {"created_time": "2016", "id": "7", ' + '"message": "Test 6"}, {"created_time": "2016", "id": "7", ' +
'"message": "Test 7"}], "paging": {"next":"' + url2 + '", ' + '"message": "Test 7"}], "paging": {"next":"' + url2 + '", ' +
'"previous": null}}', '"previous": null}}',
body2 = '{"data": [], "paging": {"next": null, "previous": null}}', body2 = '{"data": [], "paging": {"next": null, "previous": null}}',
server = this.server, server = this.server,
return_object = {"data": { return_object = {"data": {
"rows": [ "rows": [
{ {
"id": "3", "id": "3",
"value": {} "value": {}
}, },
{ {
"id": "4", "id": "4",
"value": {} "value": {}
}, },
{ {
"id": "5", "id": "5",
"value": {} "value": {}
} }
], ],
"total_rows": 3 "total_rows": 3
} }
}; };
this.server.respondWith("GET", url1, [200, { this.server.respondWith("GET", url1, [200, {
"Content-Type": "text/xml" "Content-Type": "text/xml"
}, body1 }, body1
]); ]);
this.server.respondWith("GET", url2, [200, { this.server.respondWith("GET", url2, [200, {
"Content-Type": "text/xml" "Content-Type": "text/xml"
}, body2 }, body2
]); ]);
stop(); stop();
expect(10); expect(10);
this.jio.allDocs({'limit': [2, 5]}) this.jio.allDocs({'limit': [2, 5]})
.then(function (result) { .then(function (result) {
equal(server.requests.length, 2); equal(server.requests.length, 2);
equal(server.requests[0].method, "GET"); equal(server.requests[0].method, "GET");
equal(server.requests[1].method, "GET"); equal(server.requests[1].method, "GET");
equal(server.requests[0].url, url1); equal(server.requests[0].url, url1);
equal(server.requests[1].url, url2); equal(server.requests[1].url, url2);
equal(server.requests[0].status, 200); equal(server.requests[0].status, 200);
equal(server.requests[1].status, 200); equal(server.requests[1].status, 200);
equal(server.requests[0].responseText, body1); equal(server.requests[0].responseText, body1);
equal(server.requests[1].responseText, body2); equal(server.requests[1].responseText, body2);
deepEqual(result, return_object); deepEqual(result, return_object);
}) })
.fail(function (error) { .fail(function (error) {
ok(false, error); ok(false, error);
}) })
.always(function () { .always(function () {
start(); start();
}); });
});
}); });
}(jIO, QUnit, sinon)); }(jIO, QUnit, sinon));
\ No newline at end of file
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