Mercurial > hg > dml-open-vis
comparison src/DML/MainVisBundle/Resources/assets/jasmine/helpers.js @ 0:493bcb69166c
added public content
author | Daniel Wolff |
---|---|
date | Tue, 09 Feb 2016 20:54:02 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:493bcb69166c |
---|---|
1 (function(){ | |
2 | |
3 var localStorageDumps = {}; | |
4 jasmine.helpers = { | |
5 | |
6 dumpStorage: function(dumpName) { | |
7 var realDumpName = _.isString(dumpName) ? dumpName : ""; | |
8 localStorageDumps[realDumpName] = {}; | |
9 var dump = localStorageDumps[realDumpName]; | |
10 for (var i = 0, len = localStorage.length; i < len; ++i) { | |
11 dump[localStorage.key(i)] = localStorage.getItem(localStorage.key(i)); | |
12 } | |
13 }, | |
14 | |
15 clearStorage: function() { | |
16 localStorage.clear(); | |
17 }, | |
18 | |
19 restoreStorageFromDump: function(dumpName) { | |
20 var realDumpName = _.isString(dumpName) ? dumpName : ""; | |
21 var localStorageDump = localStorageDumps[realDumpName]; | |
22 localStorage.clear(); | |
23 if (_.isObject(localStorageDump)) { | |
24 for(var key in localStorageDump) { | |
25 if (localStorageDump.hasOwnProperty(key)) { | |
26 localStorage.setItem(key,localStorageDump[key]); | |
27 } | |
28 } | |
29 } | |
30 } | |
31 }; | |
32 })(); |