Commit c60c5419 authored by Tristan Cavelier's avatar Tristan Cavelier

Improving jio tests

Tests works now on a virtual local storage
parent 5c5b80be
...@@ -472,9 +472,7 @@ test ('Document load', function () { ...@@ -472,9 +472,7 @@ test ('Document load', function () {
o.jio.loadDocument('file',{onResponse:o.f,max_retry:1}); o.jio.loadDocument('file',{onResponse:o.f,max_retry:1});
o.tick(); o.tick();
LocalOrCookieStorage.setItem ( addFileToLocalStorage('MrLoadName','jiotests',o.doc);
'jio/local_file_name_array/MrLoadName/jiotests',['file']);
LocalOrCookieStorage.setItem ('jio/local/MrLoadName/jiotests/file',o.doc);
o.spy('value',o.doc,'loading document success'); o.spy('value',o.doc,'loading document success');
o.jio.loadDocument('file',{onResponse:o.f,max_retry:1}); o.jio.loadDocument('file',{onResponse:o.f,max_retry:1});
o.tick(); o.tick();
...@@ -543,7 +541,7 @@ test ('Document remove', function () { ...@@ -543,7 +541,7 @@ test ('Document remove', function () {
o.jio = JIO.newJio({type:'local',username:'MrRemoveName', o.jio = JIO.newJio({type:'local',username:'MrRemoveName',
applicationname:'jiotests'}); applicationname:'jiotests'});
// test removing a file // test removing a file
LocalOrCookieStorage.setItem ('jio/local/MrRemoveName/jiotests/file',{}); addFileToLocalStorage ('MrRemoveName','jiotests',{name:'file'});
o.mytest (); o.mytest ();
o.jio.stop(); o.jio.stop();
...@@ -1188,7 +1186,7 @@ if (window.requirejs) { ...@@ -1188,7 +1186,7 @@ if (window.requirejs) {
paths: { paths: {
jiotestsloader: './jiotests.loader', jiotestsloader: './jiotests.loader',
LocalOrCookieStorage: '../lib/jio/localorcookiestorage.min', LocalOrCookieStorage: './testlocalorcookiestorage',
jQueryAPI: '../lib/jquery/jquery', jQueryAPI: '../lib/jquery/jquery',
jQuery: '../js/jquery.requirejs_module', jQuery: '../js/jquery.requirejs_module',
JIO: '../src/jio', JIO: '../src/jio',
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
<script type="text/javascript" src="../lib/sinon/sinon.js"></script> <script type="text/javascript" src="../lib/sinon/sinon.js"></script>
<script type="text/javascript" src="../lib/sinon/sinon-qunit.js"></script> <script type="text/javascript" src="../lib/sinon/sinon-qunit.js"></script>
<script type="text/javascript" src="../lib/jquery/jquery.js"></script> <script type="text/javascript" src="../lib/jquery/jquery.js"></script>
<script type="text/javascript" src="../src/localorcookiestorage.js"> <script type="text/javascript" src="./testlocalorcookiestorage.js"></script>
</script>
<script type="text/javascript" src="../lib/jio/jio.js"></script> <script type="text/javascript" src="../lib/jio/jio.js"></script>
<script type="text/javascript" src="../src/jio/activityUpdater.js"></script> <script type="text/javascript" src="../src/jio/activityUpdater.js"></script>
......
var LocalOrCookieStorage = (function () {
var tmp = function () {
this.storage = {};
};
tmp.prototype = {
getItem: function (k) {
var v = (typeof this.storage[k] === 'undefined' ?
null: this.storage[k]);
return JSON.parse (v);
},
setItem: function (k,v) {
this.storage[k] = JSON.stringify (v);
},
deleteItem: function (k) {
delete this.storage[k];
},
getAll: function () {
return this.storage;
}
};
return new tmp();
}());
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