This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Sleep timer that can also cancel the request | |
* | |
* @param ms | |
* @param isCancelled | |
* @returns {Promise<any>} | |
*/ | |
const sleep = (ms, isCancelled) => { | |
let timeoutHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mocks localStorage | |
const localStorageMock = (function() { | |
let store = {}; | |
return { | |
getItem: (key) => store[key] || null, | |
setItem: (key, value) => store[key] = value.toString(), | |
clear: () => store = {} | |
}; |