@@ -12,18 +12,21 @@ describe("i18n", () => {
1212 beforeEach ( async ( ) => {
1313 // Create temporary directory for test files
1414 tempDir = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , "code-server-i18n-test-" ) )
15-
15+
1616 // Create test files
1717 validJsonFile = path . join ( tempDir , "valid.json" )
1818 invalidJsonFile = path . join ( tempDir , "invalid.json" )
1919 nonExistentFile = path . join ( tempDir , "does-not-exist.json" )
2020
2121 // 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+ )
2730
2831 // Write invalid JSON file
2932 await fs . writeFile ( invalidJsonFile , '{"WELCOME": "Missing closing quote}' )
@@ -42,44 +45,51 @@ describe("i18n", () => {
4245
4346 it ( "should throw clear error for non-existent file" , async ( ) => {
4447 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.` ,
4649 )
4750 } )
4851
4952 it ( "should throw clear error for invalid JSON" , async ( ) => {
5053 await expect ( loadCustomStrings ( invalidJsonFile ) ) . rejects . toThrow (
51- `Invalid JSON in custom strings file: ${ invalidJsonFile } `
54+ `Invalid JSON in custom strings file: ${ invalidJsonFile } ` ,
5255 )
5356 } )
5457
5558 it ( "should handle empty JSON object" , async ( ) => {
5659 const emptyJsonFile = path . join ( tempDir , "empty.json" )
5760 await fs . writeFile ( emptyJsonFile , "{}" )
58-
61+
5962 await expect ( loadCustomStrings ( emptyJsonFile ) ) . resolves . toBeUndefined ( )
6063 } )
6164
6265 it ( "should handle nested JSON objects" , async ( ) => {
6366 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+
7177 await expect ( loadCustomStrings ( nestedJsonFile ) ) . resolves . toBeUndefined ( )
7278 } )
7379
7480 it ( "should handle special characters and unicode" , async ( ) => {
7581 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+
8292 await expect ( loadCustomStrings ( unicodeJsonFile ) ) . resolves . toBeUndefined ( )
8393 } )
8494 } )
85- } )
95+ } )
0 commit comments