@@ -363,6 +363,9 @@ describe('PollCreationDialog', () => {
363363 const createPollSpy = jest
364364 . spyOn ( client , 'createPoll' )
365365 . mockImplementationOnce ( ( ) => Promise . resolve ( { poll } ) ) ;
366+ const initPollStateSpy = jest
367+ . spyOn ( channel . messageComposer . pollComposer , 'initState' )
368+ . mockImplementation ( ) ;
366369
367370 await act ( async ( ) => {
368371 await fireEvent . change ( getNameInput ( ) , { target : { value : formState . name } } ) ;
@@ -407,14 +410,25 @@ describe('PollCreationDialog', () => {
407410 expect . objectContaining ( expectedPollPayload ) ,
408411 ) ;
409412 expect ( close ) . toHaveBeenCalledTimes ( 1 ) ;
413+ expect ( initPollStateSpy ) . toHaveBeenCalledTimes ( 1 ) ;
410414 } ) ;
411415 } ) ;
412416
413417 it ( 'closes the form on cancel' , async ( ) => {
414- await renderComponent ( ) ;
418+ const {
419+ channels : [ channel ] ,
420+ client,
421+ } = await initClientWithChannels ( { customUser : user } ) ;
422+ const initPollStateSpy = jest
423+ . spyOn ( channel . messageComposer . pollComposer , 'initState' )
424+ . mockImplementation ( ) ;
425+
426+ await renderComponent ( { channel, client } ) ;
427+
415428 act ( ( ) => {
416429 fireEvent . click ( screen . getByText ( CANCEL_BUTTON_TEXT ) ) ;
417430 } ) ;
418431 expect ( close ) . toHaveBeenCalledTimes ( 1 ) ;
432+ expect ( initPollStateSpy ) . toHaveBeenCalledTimes ( 1 ) ;
419433 } ) ;
420434} ) ;
0 commit comments