|
@@ -75,7 +75,7 @@ describe( 'MarkersCollection', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
describe( 'remove', () => {
|
|
describe( 'remove', () => {
|
|
|
- it( 'should return true and fire remove event if range is removed - passed name', () => {
|
|
|
|
|
|
|
+ it( 'should return true and fire remove event if range is removed', () => {
|
|
|
markers.add( 'name', live );
|
|
markers.add( 'name', live );
|
|
|
|
|
|
|
|
sinon.spy( markers, 'fire' );
|
|
sinon.spy( markers, 'fire' );
|
|
@@ -92,36 +92,10 @@ describe( 'MarkersCollection', () => {
|
|
|
expect( markers.fire.calledWith( 'remove' ) ).to.be.true;
|
|
expect( markers.fire.calledWith( 'remove' ) ).to.be.true;
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should return true and fire remove event if range is removed - passed range', () => {
|
|
|
|
|
- markers.add( 'name', live );
|
|
|
|
|
-
|
|
|
|
|
- sinon.spy( markers, 'fire' );
|
|
|
|
|
-
|
|
|
|
|
- markers.on( 'remove', ( evt, name, range ) => {
|
|
|
|
|
- expect( name ).to.equal( 'name' );
|
|
|
|
|
- expect( range.isEqual( live ) ).to.be.true;
|
|
|
|
|
- expect( range ).not.to.equal( live );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- const result = markers.remove( live );
|
|
|
|
|
-
|
|
|
|
|
- expect( result ).to.be.true;
|
|
|
|
|
- expect( markers.fire.calledWith( 'remove' ) ).to.be.true;
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
it( 'should return false if name has not been found in collection', () => {
|
|
it( 'should return false if name has not been found in collection', () => {
|
|
|
- const result = markers.remove( 'name' );
|
|
|
|
|
-
|
|
|
|
|
- expect( result ).to.be.false;
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'should return false if range has not been found in collection', () => {
|
|
|
|
|
markers.add( 'name', live );
|
|
markers.add( 'name', live );
|
|
|
|
|
|
|
|
- const other = LiveRange.createFromParentsAndOffsets( root, 0, root, 4 );
|
|
|
|
|
- const result = markers.remove( other );
|
|
|
|
|
-
|
|
|
|
|
- other.detach();
|
|
|
|
|
|
|
+ const result = markers.remove( 'other' );
|
|
|
|
|
|
|
|
expect( result ).to.be.false;
|
|
expect( result ).to.be.false;
|
|
|
} );
|
|
} );
|
|
@@ -138,7 +112,7 @@ describe( 'MarkersCollection', () => {
|
|
|
newLive.detach();
|
|
newLive.detach();
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should return true and use remove and add methods if range was found in collection - passed name', () => {
|
|
|
|
|
|
|
+ it( 'should return true and use remove and add methods if range was found in collection', () => {
|
|
|
const newLive = LiveRange.createFromParentsAndOffsets( root, 1, root, 5 );
|
|
const newLive = LiveRange.createFromParentsAndOffsets( root, 1, root, 5 );
|
|
|
markers.add( 'name', live );
|
|
markers.add( 'name', live );
|
|
|
|
|
|
|
@@ -154,33 +128,11 @@ describe( 'MarkersCollection', () => {
|
|
|
newLive.detach();
|
|
newLive.detach();
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'should return true and use remove and add methods if range was found in collection - passed range', () => {
|
|
|
|
|
- const newLive = LiveRange.createFromParentsAndOffsets( root, 1, root, 5 );
|
|
|
|
|
- markers.add( 'name', live );
|
|
|
|
|
-
|
|
|
|
|
- sinon.spy( markers, 'remove' );
|
|
|
|
|
- sinon.spy( markers, 'add' );
|
|
|
|
|
-
|
|
|
|
|
- const result = markers.update( live, newLive );
|
|
|
|
|
-
|
|
|
|
|
- expect( markers.remove.calledWith( 'name' ) ).to.be.true;
|
|
|
|
|
- expect( markers.add.calledWith( 'name', newLive ) ).to.be.true;
|
|
|
|
|
- expect( result ).to.be.true;
|
|
|
|
|
-
|
|
|
|
|
- newLive.detach();
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
it( 'should return false if given name was not found in collection', () => {
|
|
it( 'should return false if given name was not found in collection', () => {
|
|
|
const result = markers.update( 'name', newLive );
|
|
const result = markers.update( 'name', newLive );
|
|
|
|
|
|
|
|
expect( result ).to.be.false;
|
|
expect( result ).to.be.false;
|
|
|
} );
|
|
} );
|
|
|
-
|
|
|
|
|
- it( 'should return false if given range was not found in collection', () => {
|
|
|
|
|
- const result = markers.update( live, newLive );
|
|
|
|
|
-
|
|
|
|
|
- expect( result ).to.be.false;
|
|
|
|
|
- } );
|
|
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
describe( 'destroy', () => {
|
|
describe( 'destroy', () => {
|