|
| 1 | +import Helpers from '../test-helpers'; |
| 2 | + |
| 3 | +const { module, test } = Helpers; |
| 4 | + |
| 5 | +let editor, editorElement; |
| 6 | + |
| 7 | +function renderEditor(...args) { |
| 8 | + editor = Helpers.mobiledoc.renderInto(editorElement, ...args); |
| 9 | + editor.selectRange(editor.post.tailPosition()); |
| 10 | + return editor; |
| 11 | +} |
| 12 | + |
| 13 | +module('Acceptance: Editor: Attributes', { |
| 14 | + beforeEach() { |
| 15 | + editorElement = $('#editor')[0]; |
| 16 | + }, |
| 17 | + afterEach() { |
| 18 | + if (editor) { editor.destroy(); } |
| 19 | + } |
| 20 | +}); |
| 21 | + |
| 22 | +test('pressing ENTER at the end of an aligned paragraph maintains the alignment (bug #694)', (assert) => { |
| 23 | + renderEditor(({post, markupSection, marker}) => { |
| 24 | + return post([ |
| 25 | + markupSection( |
| 26 | + 'p', |
| 27 | + [marker('abc')], |
| 28 | + false, |
| 29 | + { 'data-md-text-align': 'center' } |
| 30 | + ) |
| 31 | + ]); |
| 32 | + }); |
| 33 | + |
| 34 | + Helpers.dom.triggerEnter(editor); |
| 35 | + |
| 36 | + const firstParagraph = document.querySelector('#editor p:first-of-type'); |
| 37 | + assert.equal(firstParagraph.getAttribute('data-md-text-align'), 'center'); |
| 38 | +}); |
| 39 | + |
| 40 | +test('toggling the section inside an aligned list maintains the alignment of the list (bug #694)', (assert) => { |
| 41 | + renderEditor(({post, listSection, listItem, marker}) => { |
| 42 | + return post([ |
| 43 | + listSection( |
| 44 | + 'ul', |
| 45 | + [ |
| 46 | + listItem([marker('abc')]), |
| 47 | + listItem([marker('123')]) |
| 48 | + ], |
| 49 | + { 'data-md-text-align': 'center' } |
| 50 | + ) |
| 51 | + ]); |
| 52 | + }); |
| 53 | + |
| 54 | + editor.run(postEditor => postEditor.toggleSection('h1')); |
| 55 | + |
| 56 | + const ul = document.querySelector('#editor ul'); |
| 57 | + assert.equal(ul.getAttribute('data-md-text-align'), 'center'); |
| 58 | +}); |
0 commit comments