@@ -16,11 +16,11 @@ runtime: /tmp/runtime
16
16
describe ( "getEnvPaths" , ( ) => {
17
17
describe ( "on darwin" , ( ) => {
18
18
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
+ // }
24
24
beforeAll ( ( ) => {
25
25
ORIGINAL_PLATFORM = process . platform
26
26
@@ -30,25 +30,15 @@ describe("getEnvPaths", () => {
30
30
} )
31
31
32
32
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 ( )
39
35
jest . mock ( "env-paths" , ( ) => {
40
36
return ( ) => ( {
41
37
data : "/home/envPath/.local/share" ,
42
38
config : "/home/envPath/.config" ,
43
39
temp : "/tmp/envPath/runtime" ,
44
40
} )
45
41
} )
46
-
47
- getEnvPaths = require ( "../../../src/node/util" ) . getEnvPaths
48
- } )
49
-
50
- afterEach ( ( ) => {
51
- jest . resetModules ( )
52
42
} )
53
43
54
44
afterAll ( ( ) => {
@@ -60,56 +50,22 @@ describe("getEnvPaths", () => {
60
50
} )
61
51
62
52
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
63
59
const envPaths = getEnvPaths ( )
64
60
65
61
expect ( envPaths . data ) . toEqual ( "/home/usr/.local/share/code-server" )
66
62
expect ( envPaths . config ) . toEqual ( "/home/usr/.config/code-server" )
67
63
expect ( envPaths . runtime ) . toEqual ( "/tmp/runtime/code-server" )
68
64
} )
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
- } )
85
65
86
- beforeEach ( ( ) => {
66
+ it ( "should return the env paths using envPaths when xdgBasedir is undefined" , ( ) => {
87
67
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
113
69
const envPaths = getEnvPaths ( )
114
70
115
71
expect ( envPaths . data ) . toEqual ( "/home/envPath/.local/share" )
0 commit comments