diff --git a/src/autosave.js b/src/autosave.js index 5404344..2b0fd09 100644 --- a/src/autosave.js +++ b/src/autosave.js @@ -68,7 +68,7 @@ export default class Autosave extends Plugin { // A minimum amount of time that needs to pass after the last action. // After that time the provided save callbacks are being called. - const waitingTime = config.waitingTime || 2000; + const waitingTime = config.waitingTime || 1000; /** * The adapter is an object with a `save()` method. That method will be called whenever @@ -347,7 +347,7 @@ mix( Autosave, ObservableMixin ); * save( editor ) { * return saveData( editor.getData() ); * }, - * waitingTime: 1000 + * waitingTime: 2000 * } * } ); * .then( ... ) diff --git a/tests/autosave.js b/tests/autosave.js index 0a56145..ecbbea8 100644 --- a/tests/autosave.js +++ b/tests/autosave.js @@ -64,7 +64,7 @@ describe( 'Autosave', () => { editor.model.insertContent( new ModelText( 'foo' ), editor.model.document.selection ); } ); - sandbox.clock.tick( 2000 ); + sandbox.clock.tick( 1000 ); } ).to.not.throw(); } ); @@ -109,7 +109,7 @@ describe( 'Autosave', () => { editor.model.insertContent( new ModelText( 'foo' ), editor.model.document.selection ); } ); - sandbox.clock.tick( 2000 ); + sandbox.clock.tick( 1000 ); return Promise.resolve().then( () => { sinon.assert.calledOnce( editor.config.get( 'autosave' ).save ); @@ -128,7 +128,7 @@ describe( 'Autosave', () => { editor.model.insertContent( new ModelText( 'foo' ), editor.model.document.selection ); } ); - sandbox.clock.tick( 2000 ); + sandbox.clock.tick( 1000 ); return Promise.resolve().then( () => { sinon.assert.calledOnce( autosave.adapter.save ); @@ -148,7 +148,7 @@ describe( 'Autosave', () => { editor.model.insertContent( new ModelText( 'foo' ), editor.model.document.selection ); } ); - sandbox.clock.tick( 2000 ); + sandbox.clock.tick( 1000 ); return Promise.resolve().then( () => { sinon.assert.calledWithExactly( autosave.adapter.save, editor ); @@ -202,7 +202,7 @@ describe( 'Autosave', () => { } ); } ); - it( 'should be default to 2000', () => { + it( 'should be default to 1000', () => { element = document.createElement( 'div' ); document.body.appendChild( element ); @@ -224,7 +224,7 @@ describe( 'Autosave', () => { editor.model.insertContent( new ModelText( 'foo' ), editor.model.document.selection ); } ); - sandbox.clock.tick( 1999 ); + sandbox.clock.tick( 999 ); return Promise.resolve().then( () => { sinon.assert.notCalled( editor.config.get( 'autosave' ).save ); @@ -233,7 +233,7 @@ describe( 'Autosave', () => { return Promise.resolve(); } ).then( () => { - // Callback should be called exactly after 2000ms by default. + // Callback should be called exactly after 1000ms by default. sinon.assert.calledOnce( editor.config.get( 'autosave' ).save ); } ); } ); @@ -274,7 +274,7 @@ describe( 'Autosave', () => { editor.model.insertContent( new ModelText( 'foo' ), editor.model.document.selection ); } ); - sandbox.clock.tick( 2000 ); + sandbox.clock.tick( 1000 ); return Promise.resolve().then( () => { sinon.assert.calledOnce( autosave.adapter.save ); @@ -314,7 +314,7 @@ describe( 'Autosave', () => { sinon.assert.notCalled( spy ); - sandbox.clock.tick( 2000 ); + sandbox.clock.tick( 1000 ); return Promise.resolve().then( () => { sinon.assert.calledOnce( spy ); @@ -343,7 +343,7 @@ describe( 'Autosave', () => { expect( pendingActions.hasAny ).to.be.true; expect( pendingActions.first.message ).to.equal( 'Saving changes' ); - sandbox.clock.tick( 2000 ); + sandbox.clock.tick( 1000 ); sinon.assert.notCalled( serverActionSpy ); expect( pendingActions.hasAny ).to.be.true; @@ -376,7 +376,7 @@ describe( 'Autosave', () => { expect( pendingActions.hasAny ).to.be.true; - sandbox.clock.tick( 2000 ); + sandbox.clock.tick( 1000 ); return runPromiseCycles().then( () => { sinon.assert.calledOnce( serverActionSpy ); @@ -403,7 +403,7 @@ describe( 'Autosave', () => { expect( pendingActions.hasAny ).to.be.true; expect( pendingActions.first.message ).to.equal( 'Saving changes' ); - sandbox.clock.tick( 2000 ); + sandbox.clock.tick( 1000 ); expect( autosave.state ).to.equal( 'saving' ); return Promise.resolve().then( () => { @@ -423,7 +423,7 @@ describe( 'Autosave', () => { expect( pendingActions.hasAny ).to.be.true; sinon.assert.calledOnce( serverActionSpy ); - sandbox.clock.tick( 2000 ); + sandbox.clock.tick( 1000 ); return runPromiseCycles(); } ).then( () => { @@ -451,7 +451,7 @@ describe( 'Autosave', () => { writer.setSelection( ModelRange.createIn( editor.model.document.getRoot().getChild( 0 ) ) ); } ); - sandbox.clock.tick( 2000 ); + sandbox.clock.tick( 1000 ); return runPromiseCycles().then( () => { sinon.assert.notCalled( autosave.adapter.save ); @@ -470,13 +470,13 @@ describe( 'Autosave', () => { writer.addMarker( 'name', { usingOperation: true, range } ); } ); - sandbox.clock.tick( 2000 ); + sandbox.clock.tick( 1000 ); editor.model.change( writer => { writer.updateMarker( 'name', { range: range2 } ); } ); - sandbox.clock.tick( 2000 ); + sandbox.clock.tick( 1000 ); return runPromiseCycles().then( () => { sinon.assert.notCalled( autosave.adapter.save ); @@ -495,13 +495,13 @@ describe( 'Autosave', () => { writer.addMarker( 'name', { usingOperation: false, range } ); } ); - sandbox.clock.tick( 2000 ); + sandbox.clock.tick( 1000 ); editor.model.change( writer => { writer.updateMarker( 'name', { range: range2 } ); } ); - sandbox.clock.tick( 2000 ); + sandbox.clock.tick( 1000 ); return runPromiseCycles().then( () => { sinon.assert.notCalled( autosave.adapter.save ); @@ -519,7 +519,7 @@ describe( 'Autosave', () => { writer.addMarker( 'name', { usingOperation: true, affectsData: true, range } ); } ); - sandbox.clock.tick( 2000 ); + sandbox.clock.tick( 1000 ); return runPromiseCycles().then( () => { sinon.assert.calledOnce( autosave.adapter.save ); @@ -538,7 +538,7 @@ describe( 'Autosave', () => { writer.addMarker( 'name', { usingOperation: false, affectsData: true, range } ); } ); - sandbox.clock.tick( 2000 ); + sandbox.clock.tick( 1000 ); return runPromiseCycles().then( () => { sinon.assert.calledOnce( autosave.adapter.save ); @@ -547,7 +547,7 @@ describe( 'Autosave', () => { writer.updateMarker( 'name', { range: range2 } ); } ); - sandbox.clock.tick( 2000 ); + sandbox.clock.tick( 1000 ); return runPromiseCycles().then( () => { sinon.assert.calledTwice( autosave.adapter.save ); @@ -567,7 +567,7 @@ describe( 'Autosave', () => { writer.addMarker( 'marker-affecting-data', { usingOperation: false, affectsData: false, range } ); } ); - sandbox.clock.tick( 2000 ); + sandbox.clock.tick( 1000 ); return runPromiseCycles().then( () => { sinon.assert.calledOnce( autosave.adapter.save );