@@ -29,7 +29,7 @@ import { ChevronFace } from '../../../../src/components/structures/ContextMenu';
2929import SettingsStore from '../../../../src/settings/SettingsStore' ;
3030import { MatrixClientPeg } from '../../../../src/MatrixClientPeg' ;
3131import { LocationShareType } from '../../../../src/components/views/location/shareLocation' ;
32- import { findByTestId } from '../../../test-utils' ;
32+ import { findByTagAndTestId } from '../../../test-utils' ;
3333
3434jest . mock ( '../../../../src/components/views/location/findMapStyleUrl' , ( ) => ( {
3535 findMapStyleUrl : jest . fn ( ) . mockReturnValue ( 'test' ) ,
@@ -96,16 +96,16 @@ describe('<LocationShareMenu />', () => {
9696 } ) ;
9797
9898 const getShareTypeOption = ( component : ReactWrapper , shareType : LocationShareType ) =>
99- findByTestId ( component , `share-location-option-${ shareType } ` ) ;
99+ findByTagAndTestId ( component , `share-location-option-${ shareType } ` , 'button' ) ;
100100
101101 const getBackButton = ( component : ReactWrapper ) =>
102- findByTestId ( component , 'share-dialog-buttons-back' ) ;
102+ findByTagAndTestId ( component , 'share-dialog-buttons-back' , 'button ') ;
103103
104104 const getCancelButton = ( component : ReactWrapper ) =>
105- findByTestId ( component , 'share-dialog-buttons-cancel' ) ;
105+ findByTagAndTestId ( component , 'share-dialog-buttons-cancel' , 'button ') ;
106106
107107 const getSubmitButton = ( component : ReactWrapper ) =>
108- findByTestId ( component , 'location-picker-submit-button' ) ;
108+ findByTagAndTestId ( component , 'location-picker-submit-button' , ' button') ;
109109
110110 const setLocation = ( component : ReactWrapper ) => {
111111 // set the location
@@ -129,13 +129,13 @@ describe('<LocationShareMenu />', () => {
129129
130130 it ( 'renders location picker when only Own share type is enabled' , ( ) => {
131131 const component = getComponent ( ) ;
132- expect ( component . find ( 'ShareType' ) . length ) . toBeFalsy ( ) ;
133- expect ( component . find ( 'LocationPicker' ) . length ) . toBeTruthy ( ) ;
132+ expect ( component . find ( 'ShareType' ) . length ) . toBe ( 0 ) ;
133+ expect ( component . find ( 'LocationPicker' ) . length ) . toBe ( 1 ) ;
134134 } ) ;
135135
136136 it ( 'does not render back button when only Own share type is enabled' , ( ) => {
137137 const component = getComponent ( ) ;
138- expect ( getBackButton ( component ) . length ) . toBeFalsy ( ) ;
138+ expect ( getBackButton ( component ) . length ) . toBe ( 0 ) ;
139139 } ) ;
140140
141141 it ( 'clicking cancel button from location picker closes dialog' , ( ) => {
@@ -177,15 +177,15 @@ describe('<LocationShareMenu />', () => {
177177
178178 it ( 'renders share type switch with own and pin drop options' , ( ) => {
179179 const component = getComponent ( ) ;
180- expect ( component . find ( 'LocationPicker' ) . length ) . toBeFalsy ( ) ;
180+ expect ( component . find ( 'LocationPicker' ) . length ) . toBe ( 0 ) ;
181181
182- expect ( getShareTypeOption ( component , LocationShareType . Own ) . length ) . toBeTruthy ( ) ;
183- expect ( getShareTypeOption ( component , LocationShareType . Pin ) . length ) . toBeTruthy ( ) ;
182+ expect ( getShareTypeOption ( component , LocationShareType . Own ) . length ) . toBe ( 1 ) ;
183+ expect ( getShareTypeOption ( component , LocationShareType . Pin ) . length ) . toBe ( 1 ) ;
184184 } ) ;
185185
186186 it ( 'does not render back button on share type screen' , ( ) => {
187187 const component = getComponent ( ) ;
188- expect ( getBackButton ( component ) . length ) . toBeFalsy ( ) ;
188+ expect ( getBackButton ( component ) . length ) . toBe ( 0 ) ;
189189 } ) ;
190190
191191 it ( 'clicking cancel button from share type screen closes dialog' , ( ) => {
@@ -204,7 +204,7 @@ describe('<LocationShareMenu />', () => {
204204
205205 setShareType ( component , LocationShareType . Own ) ;
206206
207- expect ( component . find ( 'LocationPicker' ) . length ) . toBeTruthy ( ) ;
207+ expect ( component . find ( 'LocationPicker' ) . length ) . toBe ( 1 ) ;
208208 } ) ;
209209
210210 it ( 'clicking back button from location picker screen goes back to share screen' , ( ) => {
@@ -214,15 +214,15 @@ describe('<LocationShareMenu />', () => {
214214 // advance to location picker
215215 setShareType ( component , LocationShareType . Own ) ;
216216
217- expect ( component . find ( 'LocationPicker' ) . length ) . toBeTruthy ( ) ;
217+ expect ( component . find ( 'LocationPicker' ) . length ) . toBe ( 1 ) ;
218218
219219 act ( ( ) => {
220220 getBackButton ( component ) . at ( 0 ) . simulate ( 'click' ) ;
221221 component . setProps ( { } ) ;
222222 } ) ;
223223
224224 // back to share type
225- expect ( component . find ( 'ShareType' ) . length ) . toBeTruthy ( ) ;
225+ expect ( component . find ( 'ShareType' ) . length ) . toBe ( 1 ) ;
226226 } ) ;
227227
228228 it ( 'creates pin drop location share event on submission' , ( ) => {
@@ -263,20 +263,22 @@ describe('<LocationShareMenu />', () => {
263263 const component = getComponent ( ) ;
264264
265265 // The the Location picker is not visible yet
266- expect ( component . find ( 'LocationPicker' ) . length ) . toBeFalsy ( ) ;
266+ expect ( component . find ( 'LocationPicker' ) . length ) . toBe ( 0 ) ;
267267
268268 // And all 3 buttons are visible on the LocationShare dialog
269269 expect (
270270 getShareTypeOption ( component , LocationShareType . Own ) . length ,
271- ) . toBeTruthy ( ) ;
271+ ) . toBe ( 1 ) ;
272272
273273 expect (
274274 getShareTypeOption ( component , LocationShareType . Pin ) . length ,
275- ) . toBeTruthy ( ) ;
275+ ) . toBe ( 1 ) ;
276276
277- expect (
278- getShareTypeOption ( component , LocationShareType . Live ) . length ,
279- ) . toBeTruthy ( ) ;
277+ const liveButton = getShareTypeOption ( component , LocationShareType . Live ) ;
278+ expect ( liveButton . length ) . toBe ( 1 ) ;
279+
280+ // The live location button is enabled
281+ expect ( liveButton . hasClass ( "mx_AccessibleButton_disabled" ) ) . toBeFalsy ( ) ;
280282 } ) ;
281283 } ) ;
282284} ) ;
0 commit comments