Skip to content

Commit 6104acb

Browse files
committed
(refactor/test): only ignore parts of AsyncLocalStorage
- 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
1 parent 2b4b78a commit 6104acb

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

jest.config.js

-6
This file was deleted.

src/asyncLocalStorage.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// using istanbul ignore on portions of code that are not currently used internally
2+
13
interface IAsyncLocalStorage {
24
clear(): Promise<void>
35
getItem(key: string): Promise<string>
@@ -7,13 +9,13 @@ interface IAsyncLocalStorage {
79

810
export const AsyncLocalStorage: IAsyncLocalStorage = {
911
// must use wrapper functions when passing localStorage functions (https://github.com/agilgur5/mst-persist/issues/18)
10-
clear () {
12+
clear /* istanbul ignore next */ () {
1113
return callWithPromise(() => window.localStorage.clear())
1214
},
1315
getItem (key) {
1416
return callWithPromise(() => window.localStorage.getItem(key))
1517
},
16-
removeItem (key) {
18+
removeItem /* istanbul ignore next */ (key) {
1719
return callWithPromise(() => window.localStorage.removeItem(key))
1820
},
1921
setItem (key, value) {
@@ -25,6 +27,7 @@ function callWithPromise (func: Function, ...args: any[]): Promise<any> {
2527
try {
2628
return Promise.resolve(func(...args))
2729
} catch (err) {
30+
/* istanbul ignore next */
2831
return Promise.reject(err)
2932
}
3033
}

0 commit comments

Comments
 (0)