@@ -47,7 +47,7 @@ describe('I18nObjectSchema', () => {
4747} ) ;
4848
4949describe ( 'I18nLabelSchema' , ( ) => {
50- it ( 'should accept plain string (backward compatible) ' , ( ) => {
50+ it ( 'should accept plain string' , ( ) => {
5151 const result = I18nLabelSchema . parse ( 'All Active' ) ;
5252 expect ( result ) . toBe ( 'All Active' ) ;
5353 } ) ;
@@ -57,29 +57,22 @@ describe('I18nLabelSchema', () => {
5757 expect ( result ) . toBe ( '' ) ;
5858 } ) ;
5959
60- it ( 'should accept i18n object' , ( ) => {
61- const label : I18nLabel = {
60+ it ( 'should reject i18n object (no longer accepted) ' , ( ) => {
61+ expect ( ( ) => I18nLabelSchema . parse ( {
6262 key : 'views.task_list.label' ,
6363 defaultValue : 'Task List' ,
64- } ;
65-
66- const result = I18nLabelSchema . parse ( label ) ;
67- expect ( typeof result ) . toBe ( 'object' ) ;
68- expect ( ( result as I18nObject ) . key ) . toBe ( 'views.task_list.label' ) ;
64+ } ) ) . toThrow ( ) ;
6965 } ) ;
7066
71- it ( 'should accept i18n object with params' , ( ) => {
72- const label = {
67+ it ( 'should reject i18n object with params' , ( ) => {
68+ expect ( ( ) => I18nLabelSchema . parse ( {
7369 key : 'common.item_count' ,
7470 defaultValue : '{count} items' ,
7571 params : { count : 42 } ,
76- } ;
77-
78- const result = I18nLabelSchema . parse ( label ) ;
79- expect ( ( result as I18nObject ) . params ) . toEqual ( { count : 42 } ) ;
72+ } ) ) . toThrow ( ) ;
8073 } ) ;
8174
82- it ( 'should reject non-string, non-object values' , ( ) => {
75+ it ( 'should reject non-string values' , ( ) => {
8376 expect ( ( ) => I18nLabelSchema . parse ( 123 ) ) . toThrow ( ) ;
8477 expect ( ( ) => I18nLabelSchema . parse ( true ) ) . toThrow ( ) ;
8578 expect ( ( ) => I18nLabelSchema . parse ( null ) ) . toThrow ( ) ;
@@ -104,17 +97,22 @@ describe('AriaPropsSchema', () => {
10497 expect ( result . ariaLabel ) . toBe ( 'Close dialog' ) ;
10598 } ) ;
10699
107- it ( 'should accept ariaLabel as i18n object ' , ( ) => {
100+ it ( 'should accept ariaLabel as string only ' , ( ) => {
108101 const props = {
102+ ariaLabel : 'Close dialog' ,
103+ } ;
104+
105+ const result = AriaPropsSchema . parse ( props ) ;
106+ expect ( result . ariaLabel ) . toBe ( 'Close dialog' ) ;
107+ } ) ;
108+
109+ it ( 'should reject ariaLabel as i18n object (no longer accepted)' , ( ) => {
110+ expect ( ( ) => AriaPropsSchema . parse ( {
109111 ariaLabel : {
110112 key : 'common.close_dialog' ,
111113 defaultValue : 'Close dialog' ,
112114 } ,
113- } ;
114-
115- const result = AriaPropsSchema . parse ( props ) ;
116- expect ( typeof result . ariaLabel ) . toBe ( 'object' ) ;
117- expect ( ( result . ariaLabel as I18nObject ) . key ) . toBe ( 'common.close_dialog' ) ;
115+ } ) ) . toThrow ( ) ;
118116 } ) ;
119117
120118 it ( 'should accept all ARIA properties' , ( ) => {
@@ -139,20 +137,23 @@ describe('AriaPropsSchema', () => {
139137 } ) ;
140138} ) ;
141139
142- describe ( 'I18n Integration (backward compatibility)' , ( ) => {
143- it ( 'should seamlessly support both string and object in same context' , ( ) => {
144- // Simulates a record with mixed label types (migration scenario)
140+ describe ( 'I18n Integration' , ( ) => {
141+ it ( 'should only accept string labels' , ( ) => {
145142 const labels : I18nLabel [ ] = [
146143 'Plain String Label' ,
147- { key : 'labels.translated' , defaultValue : 'Translated Label' } ,
148144 'Another Plain String' ,
149- { key : 'labels.with_params' , params : { count : 10 } } ,
145+ 'Setup' ,
150146 ] ;
151147
152148 labels . forEach ( label => {
153149 expect ( ( ) => I18nLabelSchema . parse ( label ) ) . not . toThrow ( ) ;
154150 } ) ;
155151 } ) ;
152+
153+ it ( 'should reject i18n objects in label context' , ( ) => {
154+ expect ( ( ) => I18nLabelSchema . parse ( { key : 'labels.translated' , defaultValue : 'Translated Label' } ) ) . toThrow ( ) ;
155+ expect ( ( ) => I18nLabelSchema . parse ( { key : 'labels.with_params' , params : { count : 10 } } ) ) . toThrow ( ) ;
156+ } ) ;
156157} ) ;
157158
158159describe ( 'PluralRuleSchema' , ( ) => {
0 commit comments