@@ -332,5 +332,61 @@ QUnit.module('Step.isValid', moduleConfig, () => {
332332 assert . strictEqual ( $stepText . children ( ) . eq ( 0 ) . hasClass ( `${ ICON_CLASS } -${ expectedIcon } ` ) , true ) ;
333333 } ) ;
334334 } ) ;
335+ } ) ;
336+
337+ QUnit . module ( 'Step.hint' , moduleConfig , ( ) => {
338+ QUnit . test ( 'Step should not have a title attribute if the hint is not defined' , function ( assert ) {
339+ this . reinit ( {
340+ items : [ { } , { hint : undefined } , { hint : null } ]
341+ } ) ;
335342
343+ const items = this . getItems ( ) ;
344+ assert . strictEqual ( items . eq ( 0 ) . attr ( 'title' ) , undefined , 'Title is not set when hint is missing' ) ;
345+ assert . strictEqual ( items . eq ( 1 ) . attr ( 'title' ) , undefined , 'Title is not set when hint is undefined' ) ;
346+ assert . strictEqual ( items . eq ( 2 ) . attr ( 'title' ) , undefined , 'Title is not set when hint is null' ) ;
347+ } ) ;
348+
349+ QUnit . test ( 'Step should have a title attribute with the correct value when hint is defined' , function ( assert ) {
350+ this . reinit ( {
351+ items : [ { hint : '' } , { hint : 'hint text' } , { hint : 0 } , { hint : true } , { hint : NaN } ]
352+ } ) ;
353+
354+ const items = this . getItems ( ) ;
355+ assert . strictEqual ( items . eq ( 0 ) . attr ( 'title' ) , '' , 'Title is correctly set for an empty string hint' ) ;
356+ assert . strictEqual ( items . eq ( 1 ) . attr ( 'title' ) , 'hint text' , 'Title is correctly set for a text hint' ) ;
357+ assert . strictEqual ( items . eq ( 2 ) . attr ( 'title' ) , '0' , 'Title is correctly set for a numeric hint' ) ;
358+ assert . strictEqual ( items . eq ( 3 ) . attr ( 'title' ) , 'true' , 'Title is correctly set when hint is boolean' ) ;
359+ assert . strictEqual ( items . eq ( 4 ) . attr ( 'title' ) , 'NaN' , 'Title is correctly set when hint is NaN' ) ;
360+ } ) ;
361+
362+ QUnit . test ( 'Step title should update when the hint option value changes at runtime' , function ( assert ) {
363+ this . reinit ( {
364+ items : [ { hint : 'Hint value' } ]
365+ } ) ;
366+
367+ const items = this . getItems ( ) ;
368+ assert . strictEqual ( items . eq ( 0 ) . attr ( 'title' ) , 'Hint value' , 'Initial title is set correctly' ) ;
369+
370+ this . instance . option ( 'items[0].hint' , 'New hint value' ) ;
371+
372+ assert . strictEqual ( items . eq ( 0 ) . attr ( 'title' ) , 'New hint value' , 'Title is updated when hint changes' ) ;
373+ } ) ;
374+
375+ QUnit . test ( 'Step title should be removed when hint is set to undefined or null' , function ( assert ) {
376+ this . reinit ( {
377+ items : [ { hint : 'Initial hint' } ]
378+ } ) ;
379+
380+ const items = this . getItems ( ) ;
381+ assert . strictEqual ( items . eq ( 0 ) . attr ( 'title' ) , 'Initial hint' , 'Initial title is set correctly' ) ;
382+
383+ this . instance . option ( 'items[0].hint' , undefined ) ;
384+ assert . strictEqual ( items . eq ( 0 ) . attr ( 'title' ) , undefined , 'Title is removed when hint is set to undefined' ) ;
385+
386+ this . instance . option ( 'items[0].hint' , 'New hint' ) ;
387+ assert . strictEqual ( items . eq ( 0 ) . attr ( 'title' ) , 'New hint' , 'Title is set correctly after hint update' ) ;
388+
389+ this . instance . option ( 'items[0].hint' , null ) ;
390+ assert . strictEqual ( items . eq ( 0 ) . attr ( 'title' ) , undefined , 'Title is removed when hint is set to null' ) ;
391+ } ) ;
336392} ) ;
0 commit comments