@@ -73,9 +73,9 @@ describe('Message bar', () => {
7373 } ) ;
7474 it ( 'should render correctly' , ( ) => {
7575 render ( < MessageBar onSendMessage = { jest . fn } /> ) ;
76- expect ( screen . getByRole ( 'button' , { name : 'Attach button ' } ) ) . toBeTruthy ( ) ;
77- expect ( screen . queryByRole ( 'button' , { name : 'Send button ' } ) ) . toBeFalsy ( ) ;
78- expect ( screen . queryByRole ( 'button' , { name : 'Microphone button ' } ) ) . toBeFalsy ( ) ;
76+ expect ( screen . getByRole ( 'button' , { name : 'Attach' } ) ) . toBeTruthy ( ) ;
77+ expect ( screen . queryByRole ( 'button' , { name : 'Send' } ) ) . toBeFalsy ( ) ;
78+ expect ( screen . queryByRole ( 'button' , { name : 'Use microphone ' } ) ) . toBeFalsy ( ) ;
7979 expect ( screen . getByRole ( 'textbox' , { name : / S e n d a m e s s a g e .../ i } ) ) . toBeTruthy ( ) ;
8080 } ) ;
8181 it ( 'can send via enter key' , async ( ) => {
@@ -110,42 +110,42 @@ describe('Message bar', () => {
110110 const input = screen . getByRole ( 'textbox' , { name : / S e n d a m e s s a g e .../ i } ) ;
111111 await userEvent . type ( input , 'Hello world' ) ;
112112 expect ( input ) . toHaveTextContent ( 'Hello world' ) ;
113- expect ( screen . getByRole ( 'button' , { name : 'Send button ' } ) ) . toBeTruthy ( ) ;
113+ expect ( screen . getByRole ( 'button' , { name : 'Send' } ) ) . toBeTruthy ( ) ;
114114 } ) ;
115115 it ( 'can disable send button shown when text is input' , async ( ) => {
116116 render ( < MessageBar onSendMessage = { jest . fn } isSendButtonDisabled /> ) ;
117117 const input = screen . getByRole ( 'textbox' , { name : / S e n d a m e s s a g e .../ i } ) ;
118118 await userEvent . type ( input , 'Hello world' ) ;
119119 expect ( input ) . toHaveTextContent ( 'Hello world' ) ;
120- expect ( screen . getByRole ( 'button' , { name : 'Send button ' } ) ) . toBeTruthy ( ) ;
121- expect ( screen . getByRole ( 'button' , { name : 'Send button ' } ) ) . toBeDisabled ( ) ;
120+ expect ( screen . getByRole ( 'button' , { name : 'Send' } ) ) . toBeTruthy ( ) ;
121+ expect ( screen . getByRole ( 'button' , { name : 'Send' } ) ) . toBeDisabled ( ) ;
122122 } ) ;
123123 it ( 'can click send button' , async ( ) => {
124124 const spy = jest . fn ( ) ;
125125 render ( < MessageBar onSendMessage = { spy } /> ) ;
126126 const input = screen . getByRole ( 'textbox' , { name : / S e n d a m e s s a g e .../ i } ) ;
127127 await userEvent . type ( input , 'Hello world' ) ;
128128 expect ( input ) . toHaveTextContent ( 'Hello world' ) ;
129- const sendButton = screen . getByRole ( 'button' , { name : 'Send button ' } ) ;
129+ const sendButton = screen . getByRole ( 'button' , { name : 'Send' } ) ;
130130 expect ( sendButton ) . toBeTruthy ( ) ;
131131 await userEvent . click ( sendButton ) ;
132132 expect ( spy ) . toHaveBeenCalledTimes ( 1 ) ;
133133 } ) ;
134134 it ( 'can always show send button' , ( ) => {
135135 render ( < MessageBar onSendMessage = { jest . fn } alwayShowSendButton /> ) ;
136- expect ( screen . getByRole ( 'button' , { name : 'Send button ' } ) ) . toBeTruthy ( ) ;
137- expect ( screen . getByRole ( 'button' , { name : 'Send button ' } ) ) . toBeEnabled ( ) ;
136+ expect ( screen . getByRole ( 'button' , { name : 'Send' } ) ) . toBeTruthy ( ) ;
137+ expect ( screen . getByRole ( 'button' , { name : 'Send' } ) ) . toBeEnabled ( ) ;
138138 } ) ;
139139 it ( 'can disable send button if always showing' , ( ) => {
140140 render ( < MessageBar onSendMessage = { jest . fn } alwayShowSendButton isSendButtonDisabled /> ) ;
141- expect ( screen . getByRole ( 'button' , { name : 'Send button ' } ) ) . toBeTruthy ( ) ;
142- expect ( screen . getByRole ( 'button' , { name : 'Send button ' } ) ) . toBeDisabled ( ) ;
141+ expect ( screen . getByRole ( 'button' , { name : 'Send' } ) ) . toBeTruthy ( ) ;
142+ expect ( screen . getByRole ( 'button' , { name : 'Send' } ) ) . toBeDisabled ( ) ;
143143 } ) ;
144144 it ( 'can handle buttonProps tooltipContent appropriately for send' , async ( ) => {
145145 render (
146146 < MessageBar onSendMessage = { jest . fn } alwayShowSendButton buttonProps = { { send : { tooltipContent : 'Test' } } } />
147147 ) ;
148- await userEvent . click ( screen . getByRole ( 'button' , { name : 'Send button ' } ) ) ;
148+ await userEvent . click ( screen . getByRole ( 'button' , { name : 'Send' } ) ) ;
149149 expect ( screen . getByRole ( 'tooltip' , { name : 'Test' } ) ) . toBeTruthy ( ) ;
150150 } ) ;
151151 it ( 'can handle buttonProps props appropriately for send' , async ( ) => {
@@ -203,13 +203,13 @@ describe('Message bar', () => {
203203 expect ( screen . queryByRole ( 'menuitem' , { name : / L o g s / i } ) ) . toBeFalsy ( ) ;
204204 expect ( screen . queryByRole ( 'menuitem' , { name : / Y A M L - S t a t u s / i } ) ) . toBeFalsy ( ) ;
205205 expect ( screen . queryByRole ( 'menuitem' , { name : / Y A M L - A l l c o n t e n t s / i } ) ) . toBeFalsy ( ) ;
206- const attachButton = screen . getByRole ( 'button' , { name : 'Attach button ' } ) ;
206+ const attachButton = screen . getByRole ( 'button' , { name : 'Attach' } ) ;
207207 await userEvent . click ( attachButton ) ;
208208 expect ( attachToggleClickSpy ) . toHaveBeenCalledTimes ( 1 ) ;
209209 } ) ;
210210 it ( 'can hide attach button' , ( ) => {
211211 render ( < MessageBar onSendMessage = { jest . fn } hasAttachButton = { false } /> ) ;
212- expect ( screen . queryByRole ( 'button' , { name : 'Attach button ' } ) ) . toBeFalsy ( ) ;
212+ expect ( screen . queryByRole ( 'button' , { name : 'Attach' } ) ) . toBeFalsy ( ) ;
213213 } ) ;
214214 // Based on this because I had no idea how to do this and was looking around: https://stackoverflow.com/a/75562651
215215 // See also https://developer.mozilla.org/en-US/docs/Web/API/File/File for what that file variable is doing
@@ -223,17 +223,17 @@ describe('Message bar', () => {
223223 buttonProps = { { attach : { inputTestId : 'input' } } }
224224 />
225225 ) ;
226- expect ( screen . getByRole ( 'button' , { name : 'Attach button ' } ) ) . toBeTruthy ( ) ;
227- await userEvent . click ( screen . getByRole ( 'button' , { name : 'Attach button ' } ) ) ;
226+ expect ( screen . getByRole ( 'button' , { name : 'Attach' } ) ) . toBeTruthy ( ) ;
227+ await userEvent . click ( screen . getByRole ( 'button' , { name : 'Attach' } ) ) ;
228228 const file = new File ( [ 'test' ] , 'test.json' ) ;
229229 const input = screen . getByTestId ( 'input' ) as HTMLInputElement ;
230230 await userEvent . upload ( input , file ) ;
231231 expect ( input . files ) . toHaveLength ( 1 ) ;
232232 expect ( spy ) . toHaveBeenCalledTimes ( 1 ) ;
233233 } ) ;
234- it ( 'can handle buttonProps tooltipContent appropriately for attach' , async ( ) => {
234+ it ( 'can handle buttonProps tooltipContent appropriately for attach' , async ( ) => {
235235 render ( < MessageBar onSendMessage = { jest . fn } hasAttachButton buttonProps = { { attach : { tooltipContent : 'Test' } } } /> ) ;
236- await userEvent . click ( screen . getByRole ( 'button' , { name : 'Attach button ' } ) ) ;
236+ await userEvent . click ( screen . getByRole ( 'button' , { name : 'Attach' } ) ) ;
237237 expect ( screen . getByRole ( 'tooltip' , { name : 'Test' } ) ) . toBeTruthy ( ) ;
238238 } ) ;
239239 it ( 'can handle buttonProps props appropriately for attach' , async ( ) => {
@@ -251,12 +251,12 @@ describe('Message bar', () => {
251251 // --------------------------------------------------------------------------
252252 it ( 'can show stop button' , ( ) => {
253253 render ( < MessageBar onSendMessage = { jest . fn } hasStopButton handleStopButton = { jest . fn } /> ) ;
254- expect ( screen . getByRole ( 'button' , { name : 'Stop button ' } ) ) . toBeTruthy ( ) ;
254+ expect ( screen . getByRole ( 'button' , { name : 'Stop' } ) ) . toBeTruthy ( ) ;
255255 } ) ;
256256 it ( 'can call handleStopButton' , async ( ) => {
257257 const spy = jest . fn ( ) ;
258258 render ( < MessageBar onSendMessage = { jest . fn } hasStopButton handleStopButton = { spy } /> ) ;
259- await userEvent . click ( screen . getByRole ( 'button' , { name : 'Stop button ' } ) ) ;
259+ await userEvent . click ( screen . getByRole ( 'button' , { name : 'Stop' } ) ) ;
260260 expect ( spy ) . toHaveBeenCalledTimes ( 1 ) ;
261261 } ) ;
262262 it ( 'can handle buttonProps tooltipContent appropriately for stop' , async ( ) => {
@@ -268,7 +268,7 @@ describe('Message bar', () => {
268268 buttonProps = { { stop : { tooltipContent : 'Test' } } }
269269 />
270270 ) ;
271- await userEvent . click ( screen . getByRole ( 'button' , { name : 'Stop button ' } ) ) ;
271+ await userEvent . click ( screen . getByRole ( 'button' , { name : 'Stop' } ) ) ;
272272 expect ( screen . getByRole ( 'tooltip' , { name : 'Test' } ) ) . toBeTruthy ( ) ;
273273 } ) ;
274274 it ( 'can handle buttonProps props appropriately for stop' , async ( ) => {
@@ -287,12 +287,12 @@ describe('Message bar', () => {
287287 // --------------------------------------------------------------------------
288288 it ( 'can hide microphone button when window.SpeechRecognition is not there' , ( ) => {
289289 render ( < MessageBar onSendMessage = { jest . fn } hasMicrophoneButton /> ) ;
290- expect ( screen . queryByRole ( 'button' , { name : 'Microphone button ' } ) ) . toBeFalsy ( ) ;
290+ expect ( screen . queryByRole ( 'button' , { name : 'Use microphone ' } ) ) . toBeFalsy ( ) ;
291291 } ) ;
292292 it ( 'can show microphone button' , ( ) => {
293293 mockSpeechRecognition ( ) ;
294294 render ( < MessageBar onSendMessage = { jest . fn } hasMicrophoneButton /> ) ;
295- expect ( screen . getByRole ( 'button' , { name : 'Microphone button ' } ) ) . toBeTruthy ( ) ;
295+ expect ( screen . getByRole ( 'button' , { name : 'Use microphone ' } ) ) . toBeTruthy ( ) ;
296296 } ) ;
297297 it ( 'can handle buttonProps appropriately for microphone' , async ( ) => {
298298 mockSpeechRecognition ( ) ;
@@ -305,15 +305,15 @@ describe('Message bar', () => {
305305 } }
306306 />
307307 ) ;
308- await userEvent . click ( screen . getByRole ( 'button' , { name : 'Microphone button ' } ) ) ;
308+ await userEvent . click ( screen . getByRole ( 'button' , { name : 'Use microphone ' } ) ) ;
309309 expect ( screen . getByRole ( 'tooltip' , { name : 'Currently listening' } ) ) . toBeTruthy ( ) ;
310- await userEvent . click ( screen . getByRole ( 'button' , { name : 'Microphone button ' } ) ) ;
310+ await userEvent . click ( screen . getByRole ( 'button' , { name : 'Stop listening ' } ) ) ;
311311 expect ( screen . getByRole ( 'tooltip' , { name : 'Not currently listening' } ) ) . toBeTruthy ( ) ;
312312 } ) ;
313313 it ( 'can customize the listening placeholder' , async ( ) => {
314314 mockSpeechRecognition ( ) ;
315315 render ( < MessageBar onSendMessage = { jest . fn } hasMicrophoneButton listeningText = "I am listening" /> ) ;
316- await userEvent . click ( screen . getByRole ( 'button' , { name : 'Microphone button ' } ) ) ;
316+ await userEvent . click ( screen . getByRole ( 'button' , { name : 'Use microphone ' } ) ) ;
317317 const input = screen . getByRole ( 'textbox' , { name : / I a m l i s t e n i n g / i } ) ;
318318 expect ( input ) . toBeTruthy ( ) ;
319319 } ) ;
@@ -330,9 +330,9 @@ describe('Message bar', () => {
330330 } ) ;
331331 it ( 'can be controlled' , ( ) => {
332332 render ( < MessageBar onSendMessage = { jest . fn } value = "test" /> ) ;
333- expect ( screen . getByRole ( 'button' , { name : 'Attach button ' } ) ) . toBeTruthy ( ) ;
334- expect ( screen . getByRole ( 'button' , { name : 'Send button ' } ) ) . toBeTruthy ( ) ;
335- expect ( screen . queryByRole ( 'button' , { name : 'Microphone button ' } ) ) . toBeFalsy ( ) ;
333+ expect ( screen . getByRole ( 'button' , { name : 'Attach' } ) ) . toBeTruthy ( ) ;
334+ expect ( screen . getByRole ( 'button' , { name : 'Send' } ) ) . toBeTruthy ( ) ;
335+ expect ( screen . queryByRole ( 'button' , { name : 'Use microphone ' } ) ) . toBeFalsy ( ) ;
336336 expect ( screen . getByRole ( 'textbox' , { name : / S e n d a m e s s a g e .../ i } ) ) . toBeTruthy ( ) ;
337337 expect ( screen . getByRole ( 'textbox' , { name : / S e n d a m e s s a g e .../ i } ) ) . toHaveValue ( 'test' ) ;
338338 } ) ;
0 commit comments