Skip to content

Commit

Permalink
Ensure multiple markup applications are rendered appropriately
Browse files Browse the repository at this point in the history
  • Loading branch information
bantic committed Aug 10, 2015
1 parent e632b88 commit 0687c83
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/js/utils/linked-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export default class LinkedList {
let nextItem = null;
if (prevItem) {
nextItem = prevItem.next;
} else {
nextItem = this.head;
}
this.insertBefore(item, nextItem);
}
Expand Down
25 changes: 25 additions & 0 deletions tests/acceptance/editor-selections-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,31 @@ 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(editorElement, {mobiledoc: mobileDocWith2Sections});

Helpers.dom.selectText('t sect', editorElement);
Helpers.dom.triggerEvent(document, 'mouseup');

setTimeout(() => {
Helpers.toolbar.clickButton(assert, 'bold');

Helpers.dom.selectText('fir', editorElement);
Helpers.dom.triggerEvent(document, 'mouseup');

setTimeout(() => {
Helpers.toolbar.clickButton(assert, 'bold');

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();
});
});
});

// test selecting text across markers deletes intermediary markers
// test selecting text that includes entire sections deletes the sections
// test selecting text and hitting enter or keydown
22 changes: 22 additions & 0 deletions tests/unit/utils/linked-list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,28 @@ test(`#insertAfter a middle item`, (assert) => {
assert.equal(itemThree.next, null, 'itemThree next is null');
});

test('#insertAfter null reference item prepends the item', (assert) => {
let list = new LinkedList();
let item1 = new LinkedItem();
let item2 = new LinkedItem();
list.append(item1);
list.insertAfter(item2, null);

assert.equal(list.head, item2, 'item2 is appended');
assert.equal(list.tail, item1, 'item1 is at tail');
});

test('#insertBefore null reference item appends the item', (assert) => {
let list = new LinkedList();
let item1 = new LinkedItem();
let item2 = new LinkedItem();
list.append(item1);
list.insertBefore(item2, null);

assert.equal(list.tail, item2, 'item2 is appended');
assert.equal(list.head, item1, 'item1 is at head');
});

test(`#remove an only item`, (assert) => {
let list = new LinkedList();
let item = new LinkedItem();
Expand Down

0 comments on commit 0687c83

Please sign in to comment.