Skip to content

Commit

Permalink
test: create a function to return a dummy response for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
koba04 committed Jan 26, 2021
1 parent 226be29 commit 489d9f4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
export function sleep(time: number) {
return new Promise(resolve => setTimeout(resolve, time))
}

export const createResponse = (response: any, { delay } = { delay: 10 }) =>
new Promise((resolve, reject) =>
setTimeout(() => {
if (response instanceof Error) {
reject(response)
} else {
resolve(response)
}
}, delay)
)

0 comments on commit 489d9f4

Please sign in to comment.