|
@@ -134,9 +134,9 @@ describe( 'Selection', () => {
|
|
|
expect( ranges[ 0 ] ).to.be.instanceof( LiveRange );
|
|
expect( ranges[ 0 ] ).to.be.instanceof( LiveRange );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should fire update event when adding a range', () => {
|
|
|
|
|
|
|
+ it( 'should fire change:range event when adding a range', () => {
|
|
|
let spy = sinon.spy();
|
|
let spy = sinon.spy();
|
|
|
- selection.on( 'update', spy );
|
|
|
|
|
|
|
+ selection.on( 'change:range', spy );
|
|
|
|
|
|
|
|
selection.addRange( range );
|
|
selection.addRange( range );
|
|
|
|
|
|
|
@@ -182,7 +182,7 @@ describe( 'Selection', () => {
|
|
|
selection.addRange( range );
|
|
selection.addRange( range );
|
|
|
|
|
|
|
|
spy = sinon.spy();
|
|
spy = sinon.spy();
|
|
|
- selection.on( 'update', spy );
|
|
|
|
|
|
|
+ selection.on( 'change:range', spy );
|
|
|
|
|
|
|
|
ranges = selection.getRanges();
|
|
ranges = selection.getRanges();
|
|
|
|
|
|
|
@@ -228,7 +228,7 @@ describe( 'Selection', () => {
|
|
|
selection.addRange( range );
|
|
selection.addRange( range );
|
|
|
|
|
|
|
|
spy = sinon.spy();
|
|
spy = sinon.spy();
|
|
|
- selection.on( 'update', spy );
|
|
|
|
|
|
|
+ selection.on( 'change:range', spy );
|
|
|
|
|
|
|
|
oldRanges = selection.getRanges();
|
|
oldRanges = selection.getRanges();
|
|
|
|
|
|
|
@@ -321,7 +321,7 @@ describe( 'Selection', () => {
|
|
|
selection.addRange( new Range( new Position( root, [ 0, 2 ] ), new Position( root, [ 1, 4 ] ) ) );
|
|
selection.addRange( new Range( new Position( root, [ 0, 2 ] ), new Position( root, [ 1, 4 ] ) ) );
|
|
|
|
|
|
|
|
spy = sinon.spy();
|
|
spy = sinon.spy();
|
|
|
- selection.on( 'update', spy );
|
|
|
|
|
|
|
+ selection.on( 'change:range', spy );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
describe( 'InsertOperation', () => {
|
|
describe( 'InsertOperation', () => {
|
|
@@ -487,6 +487,15 @@ describe( 'Selection', () => {
|
|
|
|
|
|
|
|
expect( emptyP.getAttribute( Selection._getStoreAttributeKey( 'foo' ) ) ).to.equal( 'bar' );
|
|
expect( emptyP.getAttribute( Selection._getStoreAttributeKey( 'foo' ) ) ).to.equal( 'bar' );
|
|
|
} );
|
|
} );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should fire change:attribute event', () => {
|
|
|
|
|
+ let spy = sinon.spy();
|
|
|
|
|
+ selection.on( 'change:attribute', spy );
|
|
|
|
|
+
|
|
|
|
|
+ selection.setAttribute( 'foo', 'bar' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( spy.called ).to.be.true;
|
|
|
|
|
+ } );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
describe( 'hasAttribute', () => {
|
|
describe( 'hasAttribute', () => {
|
|
@@ -544,6 +553,15 @@ describe( 'Selection', () => {
|
|
|
expect( emptyP.getAttribute( Selection._getStoreAttributeKey( 'foo' ) ) ).to.equal( 'bar' );
|
|
expect( emptyP.getAttribute( Selection._getStoreAttributeKey( 'foo' ) ) ).to.equal( 'bar' );
|
|
|
expect( emptyP.hasAttribute( Selection._getStoreAttributeKey( 'abc' ) ) ).to.be.false;
|
|
expect( emptyP.hasAttribute( Selection._getStoreAttributeKey( 'abc' ) ) ).to.be.false;
|
|
|
} );
|
|
} );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should fire change:attribute event', () => {
|
|
|
|
|
+ let spy = sinon.spy();
|
|
|
|
|
+ selection.on( 'change:attribute', spy );
|
|
|
|
|
+
|
|
|
|
|
+ selection.setAttributesTo( { foo: 'bar' } );
|
|
|
|
|
+
|
|
|
|
|
+ expect( spy.called ).to.be.true;
|
|
|
|
|
+ } );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
describe( 'removeAttribute', () => {
|
|
describe( 'removeAttribute', () => {
|
|
@@ -566,6 +584,15 @@ describe( 'Selection', () => {
|
|
|
|
|
|
|
|
expect( emptyP.hasAttribute( Selection._getStoreAttributeKey( 'foo' ) ) ).to.be.false;
|
|
expect( emptyP.hasAttribute( Selection._getStoreAttributeKey( 'foo' ) ) ).to.be.false;
|
|
|
} );
|
|
} );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should fire change:attribute event', () => {
|
|
|
|
|
+ let spy = sinon.spy();
|
|
|
|
|
+ selection.on( 'change:attribute', spy );
|
|
|
|
|
+
|
|
|
|
|
+ selection.removeAttribute( 'foo' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( spy.called ).to.be.true;
|
|
|
|
|
+ } );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
describe( 'clearAttributes', () => {
|
|
describe( 'clearAttributes', () => {
|
|
@@ -596,6 +623,15 @@ describe( 'Selection', () => {
|
|
|
expect( emptyP.hasAttribute( Selection._getStoreAttributeKey( 'foo' ) ) ).to.be.false;
|
|
expect( emptyP.hasAttribute( Selection._getStoreAttributeKey( 'foo' ) ) ).to.be.false;
|
|
|
expect( emptyP.hasAttribute( Selection._getStoreAttributeKey( 'abc' ) ) ).to.be.false;
|
|
expect( emptyP.hasAttribute( Selection._getStoreAttributeKey( 'abc' ) ) ).to.be.false;
|
|
|
} );
|
|
} );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should fire change:attribute event', () => {
|
|
|
|
|
+ let spy = sinon.spy();
|
|
|
|
|
+ selection.on( 'change:attribute', spy );
|
|
|
|
|
+
|
|
|
|
|
+ selection.clearAttributes();
|
|
|
|
|
+
|
|
|
|
|
+ expect( spy.called ).to.be.true;
|
|
|
|
|
+ } );
|
|
|
} );
|
|
} );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
@@ -650,6 +686,15 @@ describe( 'Selection', () => {
|
|
|
selection.setRanges( [ new Range( new Position( root, [ 0, 0 ] ), new Position( root, [ 0, 0 ] ) ) ] );
|
|
selection.setRanges( [ new Range( new Position( root, [ 0, 0 ] ), new Position( root, [ 0, 0 ] ) ) ] );
|
|
|
expect( Array.from( selection.getAttributes() ) ).to.deep.equal( [] );
|
|
expect( Array.from( selection.getAttributes() ) ).to.deep.equal( [] );
|
|
|
} );
|
|
} );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should fire change:attribute event', () => {
|
|
|
|
|
+ let spy = sinon.spy();
|
|
|
|
|
+ selection.on( 'change:attribute', spy );
|
|
|
|
|
+
|
|
|
|
|
+ selection.setRanges( [ new Range( new Position( root, [ 2 ] ), new Position( root, [ 5 ] ) ) ] );
|
|
|
|
|
+
|
|
|
|
|
+ expect( spy.called ).to.be.true;
|
|
|
|
|
+ } );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
describe( '_getStoredAttributes', () => {
|
|
describe( '_getStoredAttributes', () => {
|