Skip to content

Commit

Permalink
(refactor/test): only ignore parts of AsyncLocalStorage
Browse files Browse the repository at this point in the history
- instead of the whole file, just clear and removeItem, as those two
  aren't currently used internally
  - have to use this funky style comment-in-the-middle-of-function-
    declaration for now as it won't ignore the func otherwise,
    possibly because of how it gets transpiled down to ES5

- invalid usage of localStorage functions also isn't done internally,
  so ignore the catch / Promise.reject block as well
  • Loading branch information
agilgur5 committed Nov 19, 2019
1 parent 2b4b78a commit 6104acb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
6 changes: 0 additions & 6 deletions jest.config.js

This file was deleted.

7 changes: 5 additions & 2 deletions src/asyncLocalStorage.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// using istanbul ignore on portions of code that are not currently used internally

interface IAsyncLocalStorage {
clear(): Promise<void>
getItem(key: string): Promise<string>
Expand All @@ -7,13 +9,13 @@ interface IAsyncLocalStorage {

export const AsyncLocalStorage: IAsyncLocalStorage = {
// must use wrapper functions when passing localStorage functions (https://github.com/agilgur5/mst-persist/issues/18)
clear () {
clear /* istanbul ignore next */ () {
return callWithPromise(() => window.localStorage.clear())
},
getItem (key) {
return callWithPromise(() => window.localStorage.getItem(key))
},
removeItem (key) {
removeItem /* istanbul ignore next */ (key) {
return callWithPromise(() => window.localStorage.removeItem(key))
},
setItem (key, value) {
Expand All @@ -25,6 +27,7 @@ function callWithPromise (func: Function, ...args: any[]): Promise<any> {
try {
return Promise.resolve(func(...args))
} catch (err) {
/* istanbul ignore next */
return Promise.reject(err)
}
}
Expand Down

0 comments on commit 6104acb

Please sign in to comment.