Daniel@0: (function(){ Daniel@0: Daniel@0: var localStorageDumps = {}; Daniel@0: jasmine.helpers = { Daniel@0: Daniel@0: dumpStorage: function(dumpName) { Daniel@0: var realDumpName = _.isString(dumpName) ? dumpName : ""; Daniel@0: localStorageDumps[realDumpName] = {}; Daniel@0: var dump = localStorageDumps[realDumpName]; Daniel@0: for (var i = 0, len = localStorage.length; i < len; ++i) { Daniel@0: dump[localStorage.key(i)] = localStorage.getItem(localStorage.key(i)); Daniel@0: } Daniel@0: }, Daniel@0: Daniel@0: clearStorage: function() { Daniel@0: localStorage.clear(); Daniel@0: }, Daniel@0: Daniel@0: restoreStorageFromDump: function(dumpName) { Daniel@0: var realDumpName = _.isString(dumpName) ? dumpName : ""; Daniel@0: var localStorageDump = localStorageDumps[realDumpName]; Daniel@0: localStorage.clear(); Daniel@0: if (_.isObject(localStorageDump)) { Daniel@0: for(var key in localStorageDump) { Daniel@0: if (localStorageDump.hasOwnProperty(key)) { Daniel@0: localStorage.setItem(key,localStorageDump[key]); Daniel@0: } Daniel@0: } Daniel@0: } Daniel@0: } Daniel@0: }; Daniel@0: })();