MyCrypto/spec/utils/localStorage.spec.ts
James Prado 70a2b3ca9a Update Jest & Enzyme, Add snapshot tests (#307)
* Add disclaimer modal to footer

* Remove duplicate code & unnecessary styles

* Fix formatting noise

* remove un-used css style

* Fix tslint error & add media query for modals

* Nest Media Query

* Update Jest & Enzyme, Add snapshot tests

* Fix tslint errors in /spec, Update mock localstorage

* Update types in tests, Fix tslint error

* Specify module versions for browser

* Update sendTransaction snapshot
2017-10-24 19:17:26 -07:00

38 lines
1009 B
TypeScript

import {
loadState,
saveState,
loadStatePropertyOrEmptyObject,
REDUX_STATE
} from '../../common/utils/localStorage';
describe('saveState', () => {
it('should serialize and persist state to local storage under key: "REDUX_STATE"', () => {
const persistMe = {
foo: 'bar'
};
saveState(persistMe);
expect(JSON.parse(localStorage.getItem(REDUX_STATE) as string)).toEqual(
persistMe
);
});
});
describe('loadStage', () => {
it('should return local storage under KEY: "REDUX_STATE"', () => {
const exValue = 'foo';
localStorage.setItem(REDUX_STATE, JSON.stringify(exValue));
expect(loadState()).toEqual(exValue);
});
});
describe('loadStatePropertyOrEmptyObject', () => {
it('should return property of object from local storage under KEY: "REDUX_STATE"', () => {
const serializeThis = {
one: 'foo',
two: 'bar'
};
saveState(serializeThis);
expect(loadStatePropertyOrEmptyObject('one')).toEqual(serializeThis.one);
});
});