@@ -12,18 +12,21 @@ describe("i18n", () => {
12
12
beforeEach ( async ( ) => {
13
13
// Create temporary directory for test files
14
14
tempDir = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , "code-server-i18n-test-" ) )
15
-
15
+
16
16
// Create test files
17
17
validJsonFile = path . join ( tempDir , "valid.json" )
18
18
invalidJsonFile = path . join ( tempDir , "invalid.json" )
19
19
nonExistentFile = path . join ( tempDir , "does-not-exist.json" )
20
20
21
21
// Write valid JSON file
22
- await fs . writeFile ( validJsonFile , JSON . stringify ( {
23
- "WELCOME" : "Custom Welcome" ,
24
- "LOGIN_TITLE" : "My Custom App" ,
25
- "LOGIN_BELOW" : "Please log in to continue"
26
- } ) )
22
+ await fs . writeFile (
23
+ validJsonFile ,
24
+ JSON . stringify ( {
25
+ WELCOME : "Custom Welcome" ,
26
+ LOGIN_TITLE : "My Custom App" ,
27
+ LOGIN_BELOW : "Please log in to continue" ,
28
+ } ) ,
29
+ )
27
30
28
31
// Write invalid JSON file
29
32
await fs . writeFile ( invalidJsonFile , '{"WELCOME": "Missing closing quote}' )
@@ -42,44 +45,51 @@ describe("i18n", () => {
42
45
43
46
it ( "should throw clear error for non-existent file" , async ( ) => {
44
47
await expect ( loadCustomStrings ( nonExistentFile ) ) . rejects . toThrow (
45
- `Custom strings file not found: ${ nonExistentFile } \nPlease ensure the file exists and is readable.`
48
+ `Custom strings file not found: ${ nonExistentFile } \nPlease ensure the file exists and is readable.` ,
46
49
)
47
50
} )
48
51
49
52
it ( "should throw clear error for invalid JSON" , async ( ) => {
50
53
await expect ( loadCustomStrings ( invalidJsonFile ) ) . rejects . toThrow (
51
- `Invalid JSON in custom strings file: ${ invalidJsonFile } `
54
+ `Invalid JSON in custom strings file: ${ invalidJsonFile } ` ,
52
55
)
53
56
} )
54
57
55
58
it ( "should handle empty JSON object" , async ( ) => {
56
59
const emptyJsonFile = path . join ( tempDir , "empty.json" )
57
60
await fs . writeFile ( emptyJsonFile , "{}" )
58
-
61
+
59
62
await expect ( loadCustomStrings ( emptyJsonFile ) ) . resolves . toBeUndefined ( )
60
63
} )
61
64
62
65
it ( "should handle nested JSON objects" , async ( ) => {
63
66
const nestedJsonFile = path . join ( tempDir , "nested.json" )
64
- await fs . writeFile ( nestedJsonFile , JSON . stringify ( {
65
- "WELCOME" : "Hello World" ,
66
- "NESTED" : {
67
- "KEY" : "Value"
68
- }
69
- } ) )
70
-
67
+ await fs . writeFile (
68
+ nestedJsonFile ,
69
+ JSON . stringify ( {
70
+ WELCOME : "Hello World" ,
71
+ NESTED : {
72
+ KEY : "Value" ,
73
+ } ,
74
+ } ) ,
75
+ )
76
+
71
77
await expect ( loadCustomStrings ( nestedJsonFile ) ) . resolves . toBeUndefined ( )
72
78
} )
73
79
74
80
it ( "should handle special characters and unicode" , async ( ) => {
75
81
const unicodeJsonFile = path . join ( tempDir , "unicode.json" )
76
- await fs . writeFile ( unicodeJsonFile , JSON . stringify ( {
77
- "WELCOME" : "欢迎来到 code-server" ,
78
- "LOGIN_TITLE" : "Willkommen bei {{app}}" ,
79
- "SPECIAL" : "Special chars: àáâãäåæçèéêë 🚀 ♠️ ∆"
80
- } ) , "utf8" )
81
-
82
+ await fs . writeFile (
83
+ unicodeJsonFile ,
84
+ JSON . stringify ( {
85
+ WELCOME : "欢迎来到 code-server" ,
86
+ LOGIN_TITLE : "Willkommen bei {{app}}" ,
87
+ SPECIAL : "Special chars: àáâãäåæçèéêë 🚀 ♠️ ∆" ,
88
+ } ) ,
89
+ "utf8" ,
90
+ )
91
+
82
92
await expect ( loadCustomStrings ( unicodeJsonFile ) ) . resolves . toBeUndefined ( )
83
93
} )
84
94
} )
85
- } )
95
+ } )
0 commit comments