11import { Editor } from 'mobiledoc-kit' ;
2+ import { clearSelection } from 'mobiledoc-kit/utils/selection-utils' ;
23import Helpers from '../test-helpers' ;
34import { MOBILEDOC_VERSION } from 'mobiledoc-kit/renderers/mobiledoc/0-2' ;
45
@@ -166,6 +167,8 @@ test('selecting text across markers and deleting joins markers', (assert) => {
166167} ) ;
167168
168169test ( 'select text and apply markup multiple times' , ( assert ) => {
170+ const done = assert . async ( ) ;
171+
169172 editor = new Editor ( { mobiledoc : mobileDocWith2Sections } ) ;
170173 editor . render ( editorElement ) ;
171174
@@ -174,15 +177,22 @@ test('select text and apply markup multiple times', (assert) => {
174177
175178 editor . run ( postEditor => postEditor . toggleMarkup ( 'strong' ) ) ;
176179
177- Helpers . dom . selectText ( editor , 'fir' , editorElement ) ;
178- editor . run ( postEditor => postEditor . toggleMarkup ( 'strong' ) ) ;
179- Helpers . dom . triggerEvent ( document , 'mouseup' ) ;
180+ setTimeout ( ( ) => {
181+ Helpers . dom . selectText ( editor , 'fir' , editorElement ) ;
182+ editor . run ( postEditor => postEditor . toggleMarkup ( 'strong' ) ) ;
183+ clearSelection ( ) ;
184+ Helpers . dom . triggerEvent ( document , 'mouseup' ) ;
180185
181- editor . run ( postEditor => postEditor . toggleMarkup ( 'strong' ) ) ;
186+ setTimeout ( ( ) => {
187+ editor . run ( postEditor => postEditor . toggleMarkup ( 'strong' ) ) ;
188+
189+ assert . hasElement ( 'p:contains(first section)' , 'correct first section' ) ;
190+ assert . hasElement ( 'strong:contains(fir)' , 'strong "fir"' ) ;
191+ assert . hasElement ( 'strong:contains(t sect)' , 'strong "t sect"' ) ;
182192
183- assert . hasElement ( 'p:contains(first section)' , 'correct first section' ) ;
184- assert . hasElement ( 'strong:contains(fir)' , 'strong "fir"' ) ;
185- assert . hasElement ( 'strong:contains(t sect)' , 'strong "t sect"' ) ;
193+ done ( ) ;
194+ } , 10 ) ;
195+ } , 10 ) ;
186196} ) ;
187197
188198test ( 'selecting text across markers deletes intermediary markers' , ( assert ) => {
0 commit comments