MyCrypto/spec/utils/localStorage.spec.ts
HenryNguyen5 c340246ca0 Enable no-implicit-any (#1263)
* Progress commit

* Update more types

* Fix more types

* Fix abi function types

* Fix lib types

* Fix rest of types

* Address wbobeirne changes

* Change origin and destination check
2018-03-07 17:36:05 -06:00

36 lines
1004 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' as any)).toEqual(serializeThis.one);
});
});