Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Tests: Tests for DocumentSelection#event:change:marker.
Browse files Browse the repository at this point in the history
  • Loading branch information
scofalik committed Jan 24, 2020
1 parent 98098c8 commit ca11612
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/model/documentselection.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,50 @@ describe( 'DocumentSelection', () => {

expect( selection.markers.map( marker => marker.name ) ).to.have.members( [ 'marker' ] );
} );

it( 'should fire change:marker event when selection markers change', () => {
model.change( writer => {
const spy = sinon.spy();

model.document.selection.on( 'change:marker', spy );

writer.setSelection( writer.createRange(
writer.createPositionFromPath( root, [ 2, 1 ] ),
writer.createPositionFromPath( root, [ 2, 2 ] )
) );

expect( spy.called ).to.be.false;

writer.addMarker( 'marker-1', {
range: writer.createRange(
writer.createPositionFromPath( root, [ 2, 0 ] ),
writer.createPositionFromPath( root, [ 2, 5 ] )
),
usingOperation: false
} );

expect( spy.calledOnce ).to.be.true;

writer.addMarker( 'marker-2', {
range: writer.createRange(
writer.createPositionFromPath( root, [ 2, 0 ] ),
writer.createPositionFromPath( root, [ 2, 3 ] )
),
usingOperation: false
} );

expect( spy.calledTwice ).to.be.true;
spy.resetHistory();

writer.setSelection( writer.createPositionFromPath( root, [ 2, 6 ] ) );

expect( spy.calledOnce ).to.be.true;

writer.setSelection( writer.createPositionFromPath( root, [ 2, 2 ] ) );

expect( spy.calledTwice ).to.be.true;
} );
} );
} );

describe( 'destroy()', () => {
Expand Down

0 comments on commit ca11612

Please sign in to comment.