Skip to content

Commit 28330e4

Browse files
committed
add unit tests
1 parent 1dcfee2 commit 28330e4

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

test/unit/node/cli.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ describe("parser", () => {
6767

6868
"1",
6969
"--verbose",
70+
["--app-name", "custom instance name"],
71+
["--welcome-text", "welcome to code"],
7072
"2",
7173

7274
["--locale", "ja"],
@@ -123,6 +125,8 @@ describe("parser", () => {
123125
socket: path.resolve("mumble"),
124126
"socket-mode": "777",
125127
verbose: true,
128+
"app-name": "custom instance name",
129+
"welcome-text": "welcome to code",
126130
version: true,
127131
"bind-addr": "192.169.0.1:8080",
128132
})

test/unit/node/routes/login.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,27 @@ describe("login", () => {
9292

9393
expect(htmlContent).toContain("Incorrect password")
9494
})
95+
96+
it("should return correct app-name", async () => {
97+
process.env.PASSWORD = previousEnvPassword
98+
const appName = "testnäme"
99+
const codeServer = await integration.setup([`--app-name=${appName}`], "")
100+
const resp = await codeServer.fetch("/login", { method: "GET" })
101+
102+
const htmlContent = await resp.text()
103+
expect(resp.status).toBe(200)
104+
expect(htmlContent).toContain(appName)
105+
})
106+
107+
it("should return correct welcome text", async () => {
108+
process.env.PASSWORD = previousEnvPassword
109+
const welcomeText = "Welcome to your code workspace! öäü🔐"
110+
const codeServer = await integration.setup([`--welcome-text=${welcomeText}`], "")
111+
const resp = await codeServer.fetch("/login", { method: "GET" })
112+
113+
const htmlContent = await resp.text()
114+
expect(resp.status).toBe(200)
115+
expect(htmlContent).toContain(welcomeText)
116+
})
95117
})
96118
})

0 commit comments

Comments
 (0)