Skip to content

Commit

Permalink
Make text selection test asynchronous 🔥
Browse files Browse the repository at this point in the history
This gives the SelectionChangeObserver an opportunity to fire
  • Loading branch information
ZeeJab committed Feb 6, 2020
1 parent 2e2d60a commit 192dcb6
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions tests/acceptance/editor-selections-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Editor } from 'mobiledoc-kit';
import { clearSelection } from 'mobiledoc-kit/utils/selection-utils';
import Helpers from '../test-helpers';
import { MOBILEDOC_VERSION } from 'mobiledoc-kit/renderers/mobiledoc/0-2';

Expand Down Expand Up @@ -166,6 +167,8 @@ test('selecting text across markers and deleting joins markers', (assert) => {
});

test('select text and apply markup multiple times', (assert) => {
const done = assert.async();

editor = new Editor({mobiledoc: mobileDocWith2Sections});
editor.render(editorElement);

Expand All @@ -174,15 +177,22 @@ test('select text and apply markup multiple times', (assert) => {

editor.run(postEditor => postEditor.toggleMarkup('strong'));

Helpers.dom.selectText(editor ,'fir', editorElement);
editor.run(postEditor => postEditor.toggleMarkup('strong'));
Helpers.dom.triggerEvent(document, 'mouseup');
setTimeout(() => {
Helpers.dom.selectText(editor ,'fir', editorElement);
editor.run(postEditor => postEditor.toggleMarkup('strong'));
clearSelection();
Helpers.dom.triggerEvent(document, 'mouseup');

editor.run(postEditor => postEditor.toggleMarkup('strong'));
setTimeout(() => {
editor.run(postEditor => postEditor.toggleMarkup('strong'));

assert.hasElement('p:contains(first section)', 'correct first section');
assert.hasElement('strong:contains(fir)', 'strong "fir"');
assert.hasElement('strong:contains(t sect)', 'strong "t sect"');

assert.hasElement('p:contains(first section)', 'correct first section');
assert.hasElement('strong:contains(fir)', 'strong "fir"');
assert.hasElement('strong:contains(t sect)', 'strong "t sect"');
done();
}, 10);
}, 10);
});

test('selecting text across markers deletes intermediary markers', (assert) => {
Expand Down

0 comments on commit 192dcb6

Please sign in to comment.