We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent da36dc6 commit 8836097Copy full SHA for 8836097
__tests__/localStorage.js
@@ -0,0 +1,28 @@
1
+import {
2
+ loadState,
3
+ saveState
4
+} from '../src/helpers/localStorage';
5
+
6
+describe('LocalStorage utilities', () => {
7
+ beforeEach(() => {
8
+ window.localStorage.clear();
9
+ });
10
11
+ const data = {
12
+ foo: 1
13
+ };
14
15
+ it('should save and load state', () => {
16
+ saveState(data);
17
18
+ const state = loadState();
19
+ expect(state).toMatchObject(data);
20
21
22
+ it('should not throw exceptions if localStorage is undefined', () => {
23
+ delete window.localStorage;
24
25
+ expect(saveState(data)).toBeUndefined();
26
+ expect(loadState()).toBeUndefined();
27
28
+});
0 commit comments