Skip to content

Commit 16887a4

Browse files
committed
success!
1 parent 36d0178 commit 16887a4

File tree

1 file changed

+15
-59
lines changed

1 file changed

+15
-59
lines changed

test/unit/node/util.test.ts

Lines changed: 15 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ runtime: /tmp/runtime
1616
describe("getEnvPaths", () => {
1717
describe("on darwin", () => {
1818
let ORIGINAL_PLATFORM = ""
19-
let getEnvPaths: () => {
20-
data: string
21-
config: string
22-
runtime: string
23-
}
19+
// let getEnvPaths: () => {
20+
// data: string
21+
// config: string
22+
// runtime: string
23+
// }
2424
beforeAll(() => {
2525
ORIGINAL_PLATFORM = process.platform
2626

@@ -30,25 +30,15 @@ describe("getEnvPaths", () => {
3030
})
3131

3232
beforeEach(() => {
33-
jest.mock("xdg-basedir", () => ({
34-
data: "/home/usr/.local/share",
35-
config: "/home/usr/.config",
36-
runtime: "/tmp/runtime",
37-
}))
38-
33+
// getEnvPaths = require("../../../src/node/util").getEnvPaths
34+
jest.resetModules()
3935
jest.mock("env-paths", () => {
4036
return () => ({
4137
data: "/home/envPath/.local/share",
4238
config: "/home/envPath/.config",
4339
temp: "/tmp/envPath/runtime",
4440
})
4541
})
46-
47-
getEnvPaths = require("../../../src/node/util").getEnvPaths
48-
})
49-
50-
afterEach(() => {
51-
jest.resetModules()
5242
})
5343

5444
afterAll(() => {
@@ -60,56 +50,22 @@ describe("getEnvPaths", () => {
6050
})
6151

6252
it("should return the env paths using xdgBasedir", () => {
53+
jest.mock("xdg-basedir", () => ({
54+
data: "/home/usr/.local/share",
55+
config: "/home/usr/.config",
56+
runtime: "/tmp/runtime",
57+
}))
58+
const getEnvPaths = require("../../../src/node/util").getEnvPaths
6359
const envPaths = getEnvPaths()
6460

6561
expect(envPaths.data).toEqual("/home/usr/.local/share/code-server")
6662
expect(envPaths.config).toEqual("/home/usr/.config/code-server")
6763
expect(envPaths.runtime).toEqual("/tmp/runtime/code-server")
6864
})
69-
})
70-
71-
describe("on darwin", () => {
72-
let ORIGINAL_PLATFORM = ""
73-
let getEnvPaths: () => {
74-
data: string
75-
config: string
76-
runtime: string
77-
}
78-
beforeAll(() => {
79-
ORIGINAL_PLATFORM = process.platform
80-
81-
Object.defineProperty(process, "platform", {
82-
value: "darwin",
83-
})
84-
})
8565

86-
beforeEach(() => {
66+
it("should return the env paths using envPaths when xdgBasedir is undefined", () => {
8767
jest.mock("xdg-basedir", () => ({}))
88-
89-
jest.mock("env-paths", () => {
90-
return () => ({
91-
data: "/home/envPath/.local/share",
92-
config: "/home/envPath/.config",
93-
temp: "/tmp/envPath/runtime",
94-
})
95-
})
96-
97-
getEnvPaths = require("../../../src/node/util").getEnvPaths
98-
})
99-
100-
afterEach(() => {
101-
jest.resetModules()
102-
})
103-
104-
afterAll(() => {
105-
// Restore old platform
106-
107-
Object.defineProperty(process, "platform", {
108-
value: ORIGINAL_PLATFORM,
109-
})
110-
})
111-
112-
it("should return the env paths using envPaths", () => {
68+
const getEnvPaths = require("../../../src/node/util").getEnvPaths
11369
const envPaths = getEnvPaths()
11470

11571
expect(envPaths.data).toEqual("/home/envPath/.local/share")

0 commit comments

Comments
 (0)