Skip to content

Commit 8836097

Browse files
committed
Fix coverage
1 parent da36dc6 commit 8836097

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Diff for: __tests__/localStorage.js

+28
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)