mirror of
https://github.com/coder/code-server.git
synced 2025-08-02 22:58:50 +08:00
refactor: add custom mock for serviceWorker test
This commit is contained in:
@ -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")
|
||||
|
Reference in New Issue
Block a user