File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -766,6 +766,30 @@ describe('CommentsPlugin state', () => {
766766 expect ( editor . emit ) . not . toHaveBeenCalled ( ) ;
767767 } ) ;
768768
769+ it ( 'settles when the selected event is echoed back to the plugin' , ( ) => {
770+ const { view, editor } = createPluginStateEnvironment ( ) ;
771+
772+ editor . emit . mockImplementation ( ( event , update ) => {
773+ if ( event === 'commentsUpdate' && update . type === comments_module_events . SELECTED ) {
774+ setActiveComment ( view , update . activeCommentId ) ;
775+ }
776+ } ) ;
777+
778+ setActiveComment ( view , 'comment-1' ) ;
779+ setActiveComment ( view , 'comment-2' ) ;
780+ setActiveComment ( view , 'comment-3' ) ;
781+
782+ vi . runAllTimers ( ) ;
783+
784+ expect ( editor . emit ) . toHaveBeenCalledTimes ( 1 ) ;
785+ expect ( editor . emit ) . toHaveBeenCalledWith ( 'commentsUpdate' , {
786+ type : comments_module_events . SELECTED ,
787+ activeCommentId : 'comment-3' ,
788+ } ) ;
789+ expect ( CommentsPluginKey . getState ( view . state ) . activeThreadId ) . toBe ( 'comment-3' ) ;
790+ expect ( vi . getTimerCount ( ) ) . toBe ( 0 ) ;
791+ } ) ;
792+
769793 it ( 'does not emit when the editor is destroyed before a deferred notification runs' , ( ) => {
770794 const { view, editor } = createPluginStateEnvironment ( ) ;
771795
You can’t perform that action at this time.
0 commit comments