@@ -68,4 +68,33 @@ describe('iD.uiFieldRadio', () => {
6868 expect ( onChange ) . toHaveBeenNthCalledWith ( 1 , toTags ) ;
6969 } ) ;
7070 } ) ;
71+
72+ describe ( 'radio with stringsCrossReference' , ( ) => {
73+ let context : iD . Context ;
74+ let selection : d3 . Selection ;
75+
76+ beforeEach ( ( ) => {
77+ context = iD . coreContext ( ) . assetPath ( '../dist/' ) . init ( ) ;
78+ selection = d3 . select ( document . createElement ( 'div' ) ) ;
79+ } ) ;
80+
81+ it ( 'renders option labels from .title when the referenced field has nested title/description option strings' , ( ) => {
82+ const accessField = iD . presetField ( 'access' , { type : 'combo' , key : 'access' } ) ;
83+ const field = iD . presetField ( 'access_boolean' , {
84+ type : 'radio' ,
85+ key : 'access' ,
86+ stringsCrossReference : '{access}' ,
87+ options : [ 'yes' , 'no' ] ,
88+ } , { access : accessField } ) ;
89+
90+ const instance = iD . uiFieldRadio ( field , context ) ;
91+
92+ expect ( ( ) => selection . call ( instance ) ) . not . toThrow ( ) ;
93+
94+ const labels = selection . selectAll < HTMLLabelElement , unknown > ( 'label' ) . nodes ( ) ;
95+ expect ( labels ) . toHaveLength ( 2 ) ;
96+ expect ( labels [ 0 ] . querySelector ( '.localized-text' ) ?. innerHTML ) . toBe ( 'Allowed' ) ;
97+ expect ( labels [ 1 ] . querySelector ( '.localized-text' ) ?. innerHTML ) . toBe ( 'Prohibited' ) ;
98+ } ) ;
99+ } ) ;
71100} ) ;
0 commit comments