Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d906da9

Browse files
committedMar 2, 2022
fixup!: refactor vscode tests
1 parent 7a6731e commit d906da9

File tree

1 file changed

+7
-32
lines changed

1 file changed

+7
-32
lines changed
 

‎test/unit/node/routes/vscode.test.ts

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe("vscode", () => {
2929
expect(resp.status).toBe(200)
3030
const html = await resp.text()
3131
const url = new URL(resp.url) // Check there were no redirections.
32-
expect(url.pathname + decodeURIComponent(url.search)).toBe(route)
32+
expect(url.pathname + url.search).toBe(route)
3333
switch (route) {
3434
case "/":
3535
case "/vscode/":
@@ -42,7 +42,7 @@ describe("vscode", () => {
4242
}
4343
})
4444

45-
it("should redirect to the passed in workspace", async () => {
45+
it("should redirect to the passed in workspace using human-readable query", async () => {
4646
const workspace = path.join(await tmpdir(testName), "test.code-workspace")
4747
await fs.writeFile(workspace, "")
4848
codeServer = await integration.setup(["--auth=none", workspace], "")
@@ -53,7 +53,7 @@ describe("vscode", () => {
5353
expect(url.search).toBe(`?workspace=${workspace}`)
5454
})
5555

56-
it("should redirect to the passed in directory", async () => {
56+
it("should redirect to the passed in folder using human-readable query", async () => {
5757
const folder = await tmpdir(testName)
5858
codeServer = await integration.setup(["--auth=none", folder], "")
5959

@@ -81,34 +81,21 @@ describe("vscode", () => {
8181
resp = await codeServer.fetch(route)
8282
const url = new URL(resp.url)
8383
expect(url.pathname).toBe(route)
84-
expect(decodeURIComponent(url.search)).toBe(`?folder=${folder}&workspace=${workspace}`)
84+
expect(url.search).toBe(`?folder=${folder}&workspace=${workspace}`)
8585
await resp.text()
8686
}
8787

8888
// Closing the folder should stop the redirecting.
8989
resp = await codeServer.fetch("/", undefined, { ew: "true" })
9090
let url = new URL(resp.url)
9191
expect(url.pathname).toBe("/")
92-
expect(decodeURIComponent(url.search)).toBe("?ew=true")
92+
expect(url.search).toBe("?ew=true")
9393
await resp.text()
9494

9595
resp = await codeServer.fetch("/")
9696
url = new URL(resp.url)
9797
expect(url.pathname).toBe("/")
98-
expect(decodeURIComponent(url.search)).toBe("")
99-
await resp.text()
100-
})
101-
102-
it("should add the workspace as a query param maintaining the slashes", async () => {
103-
const workspace = path.join(await tmpdir(testName), "test.code-workspace")
104-
await fs.writeFile(workspace, "")
105-
codeServer = await integration.setup(["--auth=none", workspace], "")
106-
107-
let resp = await codeServer.fetch("/", undefined)
108-
109-
expect(resp.status).toBe(200)
110-
const url = new URL(resp.url)
111-
expect(url.search).toBe(`?workspace=${workspace}`)
98+
expect(url.search).toBe("")
11299
await resp.text()
113100
})
114101

@@ -123,18 +110,6 @@ describe("vscode", () => {
123110
await resp.text()
124111
})
125112

126-
it("should add the folder as a query param maintaining the slashes", async () => {
127-
const folder = await tmpdir(testName)
128-
codeServer = await integration.setup(["--auth=none", folder], "")
129-
130-
let resp = await codeServer.fetch("/", undefined)
131-
132-
expect(resp.status).toBe(200)
133-
const url = new URL(resp.url)
134-
expect(url.search).toBe(`?folder=${folder}`)
135-
await resp.text()
136-
})
137-
138113
it("should not redirect when last opened is ignored", async () => {
139114
codeServer = await integration.setup(["--auth=none", "--ignore-last-opened"], "")
140115

@@ -151,7 +126,7 @@ describe("vscode", () => {
151126
resp = await codeServer.fetch("/")
152127
const url = new URL(resp.url)
153128
expect(url.pathname).toBe("/")
154-
expect(decodeURIComponent(url.search)).toBe("")
129+
expect(url.search).toBe("")
155130
await resp.text()
156131
})
157132
})

0 commit comments

Comments
 (0)
Please sign in to comment.