27 lines
355 B
JavaScript
27 lines
355 B
JavaScript
// @flow
|
|
class LocalStorageMock {
|
|
store: Object
|
|
|
|
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()
|