This commit is contained in:
Nathan Bierema 2021-06-16 11:39:25 -04:00
parent 96c2fd9988
commit f8685c57e0

View File

@ -3,6 +3,9 @@ import { compose, createStore } from 'redux';
describe('persistState', () => { describe('persistState', () => {
const savedLocalStorage = global.localStorage; const savedLocalStorage = global.localStorage;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
delete global.localStorage;
beforeEach(() => { beforeEach(() => {
global.localStorage = { global.localStorage = {
@ -118,9 +121,9 @@ describe('persistState', () => {
const spy = jest.spyOn(console, 'warn').mockImplementation(() => { const spy = jest.spyOn(console, 'warn').mockImplementation(() => {
// noop // noop
}); });
global.localStorage.getItem = () => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment
throw new Error(); // @ts-ignore
}; delete global.localStorage.getItem;
createStore(reducer, compose(instrument(), persistState('id'))); createStore(reducer, compose(instrument(), persistState('id')));
expect(spy.mock.calls[0]).toContain( expect(spy.mock.calls[0]).toContain(
@ -134,9 +137,9 @@ describe('persistState', () => {
const spy = jest.spyOn(console, 'warn').mockImplementation(() => { const spy = jest.spyOn(console, 'warn').mockImplementation(() => {
// noop // noop
}); });
global.localStorage.setItem = () => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment
throw new Error(); // @ts-ignore
}; delete global.localStorage.setItem;
const store = createStore( const store = createStore(
reducer, reducer,
compose(instrument(), persistState('id')) compose(instrument(), persistState('id'))