コード例 #1
0
test('inserting multiple spaces renders them with nbsps', (assert) => {
  let mobiledoc = Helpers.mobiledoc.build(({post, markupSection}) => {
    return post([markupSection()]);
  });
  editor = new Editor({mobiledoc});
  editor.render(editorElement);

  // Tests on FF fail if the editor doesn't have a cursor, we must
  // render it explicitly
  editor.selectRange(new Range(editor.post.tailPosition()));

  assert.ok(editor.hasCursor(), 'precond - has cursor');

  let sp = ' ', nbsp = NO_BREAK_SPACE;
  Helpers.dom.insertText(editor, sp + sp + sp);
  assert.equal($('#editor p:eq(0)').text(),
               nbsp + nbsp + nbsp,
               'correct nbsps in text');
});