@@ -63,44 +63,15 @@ function contrastRatio(first: string, second: string): number {
6363}
6464
6565describe ( "theme files" , ( ) => {
66- it ( "persists distinct non-Latin theme files without changing explicit or ASCII ids" , ( ) => {
67- const stored = new Map < string , string > ( ) ;
68- vi . stubGlobal ( "window" , {
69- localStorage : {
70- getItem : ( key : string ) => stored . get ( key ) ?? null ,
71- setItem : ( key : string , value : string ) => stored . set ( key , value ) ,
72- } ,
73- } ) ;
74- invalidateCustomThemes ( ) ;
75- try {
76- const file = {
77- version : THEME_FILE_VERSION ,
78- appearance : "dark" ,
79- colors : { canvas : "#101820" } ,
80- } ;
81- const night = parseThemeFile ( { ...file , name : "夜" } ) ;
82- const morning = parseThemeFile ( { ...file , name : "朝" } ) ;
83- expect ( morning . id ) . not . toBe ( night . id ) ;
84- expect ( parseThemeFile ( { ...file , name : " 夜 " } ) . id ) . toBe ( night . id ) ;
85- expect ( parseThemeFile ( { ...file , name : "Ocean Night" } ) . id ) . toBe ( "ocean-night" ) ;
86- const legacy = parseThemeFile ( { ...file , name : "旧" , id : "custom-theme" } ) ;
87- expect ( legacy . id ) . toBe ( "custom-theme" ) ;
88- const themes = [ legacy , night , morning ] ;
89- for ( const theme of themes ) {
90- installCustomTheme ( theme ) ;
91- expect ( parseThemeFile ( JSON . parse ( serializeThemeFile ( theme ) ) ) . id ) . toBe ( theme . id ) ;
92- }
93- invalidateCustomThemes ( ) ;
94- expect ( getCustomThemes ( ) . map ( ( theme ) => [ theme . id , theme . label ] ) ) . toEqual (
95- themes . map ( ( theme ) => [ theme . id , theme . label ] ) ,
96- ) ;
97- expect ( ( ) => installCustomTheme ( parseThemeFile ( { ...file , name : "夜" } ) ) ) . toThrow (
98- "already installed" ,
99- ) ;
100- } finally {
101- vi . unstubAllGlobals ( ) ;
102- invalidateCustomThemes ( ) ;
103- }
66+ it ( "gives non-Latin theme names distinct stable ids" , ( ) => {
67+ const file = {
68+ version : THEME_FILE_VERSION ,
69+ appearance : "dark" ,
70+ colors : { canvas : "#101820" } ,
71+ } ;
72+ const night = parseThemeFile ( { ...file , name : "夜" } ) ;
73+ expect ( parseThemeFile ( { ...file , name : "朝" } ) . id ) . not . toBe ( night . id ) ;
74+ expect ( parseThemeFile ( { ...file , name : " 夜 " } ) . id ) . toBe ( night . id ) ;
10475 } ) ;
10576
10677 it ( "keeps built-in and standard search pairs readable and distinct from inline code" , ( ) => {
0 commit comments