@@ -10,7 +10,12 @@ import React from 'react';
1010
1111jest . mock ( '@components/MenuItemWithTopDescription' , ( ) => {
1212 const { Text} = jest . requireActual < Record < 'Text' , React . ComponentType < { children ?: React . ReactNode } > > > ( 'react-native' ) ;
13- return ( { title} : { title : string } ) => < Text > { title } </ Text > ;
13+ return ( { title, hintText} : { title : string ; hintText ?: string } ) => (
14+ < >
15+ < Text > { title } </ Text >
16+ { hintText ? < Text > { hintText } </ Text > : null }
17+ </ >
18+ ) ;
1419} ) ;
1520
1621jest . mock ( '@hooks/useLocalize' , ( ) => ( ) => ( { translate : ( key : string ) => key . replace ( 'common.' , '' ) } ) ) ;
@@ -33,16 +38,36 @@ const defaultProps = {
3338
3439describe ( 'DistanceField' , ( ) => {
3540 it . each ( [
36- [ 1 , '1.00 mile' ] ,
37- [ 100 , '100.00 miles' ] ,
38- ] ) ( 'displays the long-form distance unit for %s miles' , ( distanceInMiles , expected ) => {
41+ [ 1 , CONST . CUSTOM_UNITS . DISTANCE_UNIT_MILES , '1.00 mile' ] ,
42+ [ 100 , CONST . CUSTOM_UNITS . DISTANCE_UNIT_MILES , '100.00 miles' ] ,
43+ [ 1 , CONST . CUSTOM_UNITS . DISTANCE_UNIT_KILOMETERS , '1.00 kilometer' ] ,
44+ [ 100 , CONST . CUSTOM_UNITS . DISTANCE_UNIT_KILOMETERS , '100.00 kilometers' ] ,
45+ ] ) ( 'displays the long-form distance unit for %s %s' , ( distance , unit , expected ) => {
3946 render (
4047 < DistanceField
4148 { ...defaultProps }
42- distance = { DistanceRequestUtils . convertToDistanceInMeters ( distanceInMiles , CONST . CUSTOM_UNITS . DISTANCE_UNIT_MILES ) }
49+ distance = { DistanceRequestUtils . convertToDistanceInMeters ( distance , unit ) }
50+ unit = { unit }
4351 /> ,
4452 ) ;
4553
4654 expect ( screen . getByText ( expected ) ) . toBeOnTheScreen ( ) ;
4755 } ) ;
56+
57+ it ( 'displays the commuter exclusion hint' , ( ) => {
58+ render (
59+ < DistanceField
60+ { ...defaultProps }
61+ distance = { DistanceRequestUtils . convertToDistanceInMeters ( 3 , CONST . CUSTOM_UNITS . DISTANCE_UNIT_MILES ) }
62+ customUnit = { {
63+ quantity : 4 ,
64+ distanceUnit : CONST . CUSTOM_UNITS . DISTANCE_UNIT_MILES ,
65+ commuterExclusion : 1 ,
66+ reimbursableDistance : 3 ,
67+ } }
68+ /> ,
69+ ) ;
70+
71+ expect ( screen . getByText ( 'distance.commuterExclusion.removedCommuterDistance.mi' ) ) . toBeOnTheScreen ( ) ;
72+ } ) ;
4873} ) ;
0 commit comments