Skip to content

Commit

Permalink
Use builder for marker clone
Browse files Browse the repository at this point in the history
  • Loading branch information
mixonic committed Aug 11, 2015
1 parent c57db03 commit 41a8214
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);
}

empty() {
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].empty(), '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 41a8214

Please sign in to comment.