Skip to content

Commit

Permalink
Merge pull request #64 from mixonic/cloned-nodes-need-builder
Browse files Browse the repository at this point in the history
Use builder for marker clone
  • Loading branch information
bantic committed Aug 11, 2015
2 parents a34b625 + 41a8214 commit 9812177
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/js/models/marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Marker = class Marker extends LinkedItem {

clone() {
const clonedMarkups = this.markups.slice();
return new this.constructor(this.value, clonedMarkups);
return this.builder.createMarker(this.value, clonedMarkups);
}

get isEmpty() {
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/models/marker-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,11 @@ test('#split creates an initial empty marker if the offset is 0', (assert) => {
assert.equal(afterMarkers[0].value, 'hi there!');
assert.ok(afterMarkers[1].isEmpty, 'final afterMarker is empty');
});

test('#clone a marker', (assert) => {
const marker = builder.createMarker('hi there!');
const cloned = marker.clone();
assert.equal(marker.builder, cloned.builder, 'builder is present');
assert.equal(marker.value, cloned.value, 'value is present');
assert.equal(marker.markups.length, cloned.markups.length, 'markup length is the same');
});

0 comments on commit 9812177

Please sign in to comment.