Skip to content

Commit 174c140

Browse files
committed
wip: add more notes
1 parent 0fa078b commit 174c140

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

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

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @jest-environment jsdom
33
*/
4+
import fetchMock from "jest-fetch-mock"
45
import { JSDOM } from "jsdom"
56
import {
67
getNlsConfiguration,
@@ -20,6 +21,11 @@ describe("vscode", () => {
2021
// We use underscores to not confuse with global values
2122
const { window: _window } = new JSDOM()
2223
_document = _window.document
24+
fetchMock.enableMocks()
25+
})
26+
27+
afterEach(() => {
28+
fetchMock.resetMocks()
2329
})
2430

2531
it("should throw an error if no nlsConfigElement", () => {
@@ -75,18 +81,15 @@ describe("vscode", () => {
7581

7682
expect(nlsConfig._resolvedLanguagePackCoreLocation).not.toBe(undefined)
7783
expect(nlsConfig.loadBundle).not.toBe(undefined)
84+
7885
// TODO@jsjoeio write the tests here
7986
// 1. call nlsConfig.loadBundle()
8087
// 2. check that fetch was called
8188
// 3. check that the callback was called and has the right json
89+
// see https://www.npmjs.com/package/jest-fetch-mock#usage
90+
// see https://www.leighhalliday.com/mock-fetch-jest
91+
fetchMock.mockOnce(JSON.stringify({ key: "hello world" }))
8292
// 4. call it again and calls the callback with the cached json
83-
/*
84-
A couple unknowns still...
85-
86-
I need to figure out how to mock the fetch call.
87-
88-
Once I do that, I can write the tests.
89-
*/
9093

9194
_document.body.removeChild(mockElement)
9295
})

0 commit comments

Comments
 (0)