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

Commit

Permalink
Modified default waitingTime to 1000ms.
Browse files Browse the repository at this point in the history
  • Loading branch information
ma2ciek committed Aug 14, 2018
1 parent fe7f4eb commit 5e66b2a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/autosave.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -347,7 +347,7 @@ mix( Autosave, ObservableMixin );
* save( editor ) {
* return saveData( editor.getData() );
* },
* waitingTime: 1000
* waitingTime: 2000
* }
* } );
* .then( ... )
Expand Down
44 changes: 22 additions & 22 deletions tests/autosave.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
} );

Expand Down Expand Up @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );
Expand Down Expand Up @@ -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 );

Expand All @@ -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 );
Expand All @@ -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 );
} );
} );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
Expand All @@ -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( () => {
Expand All @@ -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( () => {
Expand Down Expand Up @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );
Expand Down

0 comments on commit 5e66b2a

Please sign in to comment.