Skip to content

Commit 0483b53

Browse files
committed
wip: add test for catch block
1 parent d94947e commit 0483b53

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/unit/browser/pages/vscode.test.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe("vscode", () => {
6666

6767
_document.body.removeChild(mockElement)
6868
})
69-
it("should return have loadBundle property if _resolvedLangaugePackCoreLocation", async () => {
69+
it("should return and have a loadBundle property if _resolvedLangaugePackCoreLocation", async () => {
7070
const mockElement = _document.createElement("div")
7171
const dataSettings = {
7272
locale: "en",
@@ -99,6 +99,11 @@ describe("vscode", () => {
9999
expect(mockCallbackFn).toHaveBeenCalledWith(undefined, { key: "hello world" })
100100
// 4. call it again and calls the callback with the cached json
101101

102+
fetchMock.mockReject(new Error("fake error message"))
103+
const mockCallbackFn2 = jest.fn((error) => error)
104+
const error = await nlsConfig.loadBundle("goodbye", "es", mockCallbackFn2)
105+
expect(error.message).toEqual("fake error message")
106+
102107
_document.body.removeChild(mockElement)
103108
})
104109
})

0 commit comments

Comments
 (0)