Commit 8d661832 authored by Tristan Cavelier's avatar Tristan Cavelier Committed by Sebastien Robin

Adding Dummy storages to jiotests.

And fixing some bugs inside jio.dummystorages.js
parent ad4a0869
......@@ -12,6 +12,7 @@
<script type="text/javascript" src="unhosted/localorcookiestorage.js"></script>
<script type="text/javascript" src="unhosted/jio.js"></script>
<script type="text/javascript" src="unhosted/base64.js"></script>
<script type="text/javascript" src="jio.dummystorages.js"></script>
<script type="text/javascript" src="unhosted/jio.storage.js"></script>
<script type="text/javascript" src="sinon/sinon-1.3.4.js"></script>
<script type="text/javascript" src="sinon/sinon-qunit-1.0.0.js"></script>
......
......@@ -110,7 +110,7 @@
{'fileName':'memo',
'creationDate':20000,
'lastModified':25000
}]);
}];
res.status = job.status = 'done';
res.message = 'List received.';
jobendcallback(job);
......@@ -224,6 +224,7 @@
// 'lastModified':date,'creationDate':date}
setTimeout(function () {
var res = {};
res.status = job.status = 'fail';
res.message = 'Cannot get document list.';
res.errno = 0;
......@@ -337,6 +338,7 @@
// 'lastModified':date,'creationDate':date}
setTimeout(function () {
var res = {};
res.status = job.status = 'fail';
res.message = 'User collection not found.';
res.errno = 404;
......
......@@ -74,6 +74,63 @@ test ( 'Jio Publish/Sububscribe/Unsubscribe methods', function () {
o.jio.stop();
});
module ( 'Jio Dummy Storages' );
test ('All tests', function () {
// Tests all dummy storages from jio.dummystorages.js
// It is simple tests, but they will be used by replicate storage later
// for sync operation.
var o = {}; var clock = this.sandbox.useFakeTimers();
var t = this;
var mytest = function (message,method,retmethod,value){
o.f = function (result) {
deepEqual (result[retmethod],value,message);};
t.spy(o,'f');
o.jio[method]({'userName':'Dummy','fileName':'file',
'fileContent':'content','callback':o.f});
clock.tick(510);
if (!o.f.calledOnce)
ok(false, 'no response / too much results');
};
// All Ok Dummy Storage
o.jio = JIO.createNew({'type':'dummyallok','userName':'Dummy'},
{'ID':'jiotests'});
mytest('check name availability OK','checkNameAvailability',
'isAvailable',true);
mytest('save document OK','saveDocument','isSaved',true);
mytest('load document OK','loadDocument','document',
{'fileName':'file','fileContent':'content',
'lastModified':15000,'creationDate':10000});
mytest('get document list OK','getDocumentList','list',
[{'fileName':'file','creationDate':10000,'lastModified':15000},
{'fileName':'memo','creationDate':20000,'lastModified':25000}]);
mytest('remove document OK','removeDocument','isRemoved',true);
o.jio.stop();
// All Fail Dummy Storage
o.jio = JIO.createNew({'type':'dummyallfail','userName':'Dummy'},
{'ID':'jiotests'});
mytest('check name availability FAIL','checkNameAvailability',
'isAvailable',false);
mytest('save document FAIL','saveDocument','isSaved',false);
mytest('load document FAIL','loadDocument','document',{});
mytest('get document list FAIL','getDocumentList','list',undefined);
mytest('remove document FAIL','removeDocument','isRemoved',false);
o.jio.stop();
// All Not Found Dummy Storage
o.jio = JIO.createNew({'type':'dummyallnotfound','userName':'Dummy'},
{'ID':'jiotests'});
mytest('check name availability NOT FOUND','checkNameAvailability',
'isAvailable',true);
mytest('save document NOT FOUND','saveDocument','isSaved',true);
mytest('load document NOT FOUND','loadDocument','document',{});
mytest('get document list NOT FOUND','getDocumentList','list',undefined);
mytest('remove document NOT FOUND','removeDocument','isRemoved',true);
o.jio.stop();
});
module ( 'Jio LocalStorage' );
test ('Check name availability', function () {
......
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