refactor: add custom mock for serviceWorker test

This commit is contained in:
Joe Previte
2021-02-24 10:50:08 -07:00
parent 6b56e6572d
commit 8c14799797
9 changed files with 68 additions and 193 deletions

View File

@ -60,25 +60,6 @@ describe("emitter", () => {
emitter.dispose()
})
it("should log an error if something goes wrong", async () => {
const HELLO_WORLD = "HELLO_WORLD"
const mockCallback = jest.fn(() => "Mock function called")
const message = "You don't have access to that folder."
const emitter = new Emitter<{ event: string; callback: () => void }>()
const onHelloWorld = ({ event, callback }: { event: string; callback: () => void }): void => {
if (event === HELLO_WORLD) {
callback()
throw new Error(message)
}
}
emitter.event(onHelloWorld)
await emitter.emit({ event: HELLO_WORLD, callback: mockCallback })
})
it("should log an error if something goes wrong", async () => {
const HELLO_WORLD = "HELLO_WORLD"
const mockCallback = jest.fn(() => "Mock function called")