Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

‎__tests__/localStorage.js

Lines changed: 28 additions & 0 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /