safe-react/config/jest/LocalStorageMock.js

26 lines
338 B
JavaScript

class LocalStorageMock {
store
constructor() {
this.store = {}
}
clear() {
this.store = {}
}
getItem(key) {
return this.store[key] || null
}
setItem(key, value) {
this.store[key] = value.toString()
}
removeItem(key) {
delete this.store[key]
}
}
global.localStorage = new LocalStorageMock()