8
0
Просмотр исходного кода

Modified default waitingTime to 1000ms.

Maciej Bukowski 7 лет назад
Родитель
Сommit
8af76b9ecf
2 измененных файлов с 24 добавлено и 24 удалено
  1. 2 2
      packages/ckeditor5-autosave/src/autosave.js
  2. 22 22
      packages/ckeditor5-autosave/tests/autosave.js

+ 2 - 2
packages/ckeditor5-autosave/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.
 		// A minimum amount of time that needs to pass after the last action.
 		// After that time the provided save callbacks are being called.
 		// 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
 		 * The adapter is an object with a `save()` method. That method will be called whenever
@@ -347,7 +347,7 @@ mix( Autosave, ObservableMixin );
  *					save( editor ) {
  *					save( editor ) {
  *						return saveData( editor.getData() );
  *						return saveData( editor.getData() );
  *					},
  *					},
- *					waitingTime: 1000
+ *					waitingTime: 2000
  *				}
  *				}
  *			} );
  *			} );
  *			.then( ... )
  *			.then( ... )

+ 22 - 22
packages/ckeditor5-autosave/tests/autosave.js

@@ -64,7 +64,7 @@ describe( 'Autosave', () => {
 					editor.model.insertContent( new ModelText( 'foo' ), editor.model.document.selection );
 					editor.model.insertContent( new ModelText( 'foo' ), editor.model.document.selection );
 				} );
 				} );
 
 
-				sandbox.clock.tick( 2000 );
+				sandbox.clock.tick( 1000 );
 			} ).to.not.throw();
 			} ).to.not.throw();
 		} );
 		} );
 
 
@@ -109,7 +109,7 @@ describe( 'Autosave', () => {
 				editor.model.insertContent( new ModelText( 'foo' ), editor.model.document.selection );
 				editor.model.insertContent( new ModelText( 'foo' ), editor.model.document.selection );
 			} );
 			} );
 
 
-			sandbox.clock.tick( 2000 );
+			sandbox.clock.tick( 1000 );
 
 
 			return Promise.resolve().then( () => {
 			return Promise.resolve().then( () => {
 				sinon.assert.calledOnce( editor.config.get( 'autosave' ).save );
 				sinon.assert.calledOnce( editor.config.get( 'autosave' ).save );
@@ -128,7 +128,7 @@ describe( 'Autosave', () => {
 				editor.model.insertContent( new ModelText( 'foo' ), editor.model.document.selection );
 				editor.model.insertContent( new ModelText( 'foo' ), editor.model.document.selection );
 			} );
 			} );
 
 
-			sandbox.clock.tick( 2000 );
+			sandbox.clock.tick( 1000 );
 
 
 			return Promise.resolve().then( () => {
 			return Promise.resolve().then( () => {
 				sinon.assert.calledOnce( autosave.adapter.save );
 				sinon.assert.calledOnce( autosave.adapter.save );
@@ -148,7 +148,7 @@ describe( 'Autosave', () => {
 				editor.model.insertContent( new ModelText( 'foo' ), editor.model.document.selection );
 				editor.model.insertContent( new ModelText( 'foo' ), editor.model.document.selection );
 			} );
 			} );
 
 
-			sandbox.clock.tick( 2000 );
+			sandbox.clock.tick( 1000 );
 
 
 			return Promise.resolve().then( () => {
 			return Promise.resolve().then( () => {
 				sinon.assert.calledWithExactly( autosave.adapter.save, editor );
 				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' );
 			element = document.createElement( 'div' );
 			document.body.appendChild( element );
 			document.body.appendChild( element );
 
 
@@ -224,7 +224,7 @@ describe( 'Autosave', () => {
 						editor.model.insertContent( new ModelText( 'foo' ), editor.model.document.selection );
 						editor.model.insertContent( new ModelText( 'foo' ), editor.model.document.selection );
 					} );
 					} );
 
 
-					sandbox.clock.tick( 1999 );
+					sandbox.clock.tick( 999 );
 
 
 					return Promise.resolve().then( () => {
 					return Promise.resolve().then( () => {
 						sinon.assert.notCalled( editor.config.get( 'autosave' ).save );
 						sinon.assert.notCalled( editor.config.get( 'autosave' ).save );
@@ -233,7 +233,7 @@ describe( 'Autosave', () => {
 
 
 						return Promise.resolve();
 						return Promise.resolve();
 					} ).then( () => {
 					} ).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 );
 						sinon.assert.calledOnce( editor.config.get( 'autosave' ).save );
 					} );
 					} );
 				} );
 				} );
@@ -274,7 +274,7 @@ describe( 'Autosave', () => {
 				editor.model.insertContent( new ModelText( 'foo' ), editor.model.document.selection );
 				editor.model.insertContent( new ModelText( 'foo' ), editor.model.document.selection );
 			} );
 			} );
 
 
-			sandbox.clock.tick( 2000 );
+			sandbox.clock.tick( 1000 );
 
 
 			return Promise.resolve().then( () => {
 			return Promise.resolve().then( () => {
 				sinon.assert.calledOnce( autosave.adapter.save );
 				sinon.assert.calledOnce( autosave.adapter.save );
@@ -314,7 +314,7 @@ describe( 'Autosave', () => {
 
 
 			sinon.assert.notCalled( spy );
 			sinon.assert.notCalled( spy );
 
 
-			sandbox.clock.tick( 2000 );
+			sandbox.clock.tick( 1000 );
 
 
 			return Promise.resolve().then( () => {
 			return Promise.resolve().then( () => {
 				sinon.assert.calledOnce( spy );
 				sinon.assert.calledOnce( spy );
@@ -343,7 +343,7 @@ describe( 'Autosave', () => {
 			expect( pendingActions.hasAny ).to.be.true;
 			expect( pendingActions.hasAny ).to.be.true;
 			expect( pendingActions.first.message ).to.equal( 'Saving changes' );
 			expect( pendingActions.first.message ).to.equal( 'Saving changes' );
 
 
-			sandbox.clock.tick( 2000 );
+			sandbox.clock.tick( 1000 );
 
 
 			sinon.assert.notCalled( serverActionSpy );
 			sinon.assert.notCalled( serverActionSpy );
 			expect( pendingActions.hasAny ).to.be.true;
 			expect( pendingActions.hasAny ).to.be.true;
@@ -376,7 +376,7 @@ describe( 'Autosave', () => {
 
 
 			expect( pendingActions.hasAny ).to.be.true;
 			expect( pendingActions.hasAny ).to.be.true;
 
 
-			sandbox.clock.tick( 2000 );
+			sandbox.clock.tick( 1000 );
 
 
 			return runPromiseCycles().then( () => {
 			return runPromiseCycles().then( () => {
 				sinon.assert.calledOnce( serverActionSpy );
 				sinon.assert.calledOnce( serverActionSpy );
@@ -403,7 +403,7 @@ describe( 'Autosave', () => {
 			expect( pendingActions.hasAny ).to.be.true;
 			expect( pendingActions.hasAny ).to.be.true;
 			expect( pendingActions.first.message ).to.equal( 'Saving changes' );
 			expect( pendingActions.first.message ).to.equal( 'Saving changes' );
 
 
-			sandbox.clock.tick( 2000 );
+			sandbox.clock.tick( 1000 );
 			expect( autosave.state ).to.equal( 'saving' );
 			expect( autosave.state ).to.equal( 'saving' );
 
 
 			return Promise.resolve().then( () => {
 			return Promise.resolve().then( () => {
@@ -423,7 +423,7 @@ describe( 'Autosave', () => {
 				expect( pendingActions.hasAny ).to.be.true;
 				expect( pendingActions.hasAny ).to.be.true;
 				sinon.assert.calledOnce( serverActionSpy );
 				sinon.assert.calledOnce( serverActionSpy );
 
 
-				sandbox.clock.tick( 2000 );
+				sandbox.clock.tick( 1000 );
 
 
 				return runPromiseCycles();
 				return runPromiseCycles();
 			} ).then( () => {
 			} ).then( () => {
@@ -451,7 +451,7 @@ describe( 'Autosave', () => {
 				writer.setSelection( ModelRange.createIn( editor.model.document.getRoot().getChild( 0 ) ) );
 				writer.setSelection( ModelRange.createIn( editor.model.document.getRoot().getChild( 0 ) ) );
 			} );
 			} );
 
 
-			sandbox.clock.tick( 2000 );
+			sandbox.clock.tick( 1000 );
 
 
 			return runPromiseCycles().then( () => {
 			return runPromiseCycles().then( () => {
 				sinon.assert.notCalled( autosave.adapter.save );
 				sinon.assert.notCalled( autosave.adapter.save );
@@ -470,13 +470,13 @@ describe( 'Autosave', () => {
 				writer.addMarker( 'name', { usingOperation: true, range } );
 				writer.addMarker( 'name', { usingOperation: true, range } );
 			} );
 			} );
 
 
-			sandbox.clock.tick( 2000 );
+			sandbox.clock.tick( 1000 );
 
 
 			editor.model.change( writer => {
 			editor.model.change( writer => {
 				writer.updateMarker( 'name', { range: range2 } );
 				writer.updateMarker( 'name', { range: range2 } );
 			} );
 			} );
 
 
-			sandbox.clock.tick( 2000 );
+			sandbox.clock.tick( 1000 );
 
 
 			return runPromiseCycles().then( () => {
 			return runPromiseCycles().then( () => {
 				sinon.assert.notCalled( autosave.adapter.save );
 				sinon.assert.notCalled( autosave.adapter.save );
@@ -495,13 +495,13 @@ describe( 'Autosave', () => {
 				writer.addMarker( 'name', { usingOperation: false, range } );
 				writer.addMarker( 'name', { usingOperation: false, range } );
 			} );
 			} );
 
 
-			sandbox.clock.tick( 2000 );
+			sandbox.clock.tick( 1000 );
 
 
 			editor.model.change( writer => {
 			editor.model.change( writer => {
 				writer.updateMarker( 'name', { range: range2 } );
 				writer.updateMarker( 'name', { range: range2 } );
 			} );
 			} );
 
 
-			sandbox.clock.tick( 2000 );
+			sandbox.clock.tick( 1000 );
 
 
 			return runPromiseCycles().then( () => {
 			return runPromiseCycles().then( () => {
 				sinon.assert.notCalled( autosave.adapter.save );
 				sinon.assert.notCalled( autosave.adapter.save );
@@ -519,7 +519,7 @@ describe( 'Autosave', () => {
 				writer.addMarker( 'name', { usingOperation: true, affectsData: true, range } );
 				writer.addMarker( 'name', { usingOperation: true, affectsData: true, range } );
 			} );
 			} );
 
 
-			sandbox.clock.tick( 2000 );
+			sandbox.clock.tick( 1000 );
 
 
 			return runPromiseCycles().then( () => {
 			return runPromiseCycles().then( () => {
 				sinon.assert.calledOnce( autosave.adapter.save );
 				sinon.assert.calledOnce( autosave.adapter.save );
@@ -538,7 +538,7 @@ describe( 'Autosave', () => {
 				writer.addMarker( 'name', { usingOperation: false, affectsData: true, range } );
 				writer.addMarker( 'name', { usingOperation: false, affectsData: true, range } );
 			} );
 			} );
 
 
-			sandbox.clock.tick( 2000 );
+			sandbox.clock.tick( 1000 );
 
 
 			return runPromiseCycles().then( () => {
 			return runPromiseCycles().then( () => {
 				sinon.assert.calledOnce( autosave.adapter.save );
 				sinon.assert.calledOnce( autosave.adapter.save );
@@ -547,7 +547,7 @@ describe( 'Autosave', () => {
 					writer.updateMarker( 'name', { range: range2 } );
 					writer.updateMarker( 'name', { range: range2 } );
 				} );
 				} );
 
 
-				sandbox.clock.tick( 2000 );
+				sandbox.clock.tick( 1000 );
 
 
 				return runPromiseCycles().then( () => {
 				return runPromiseCycles().then( () => {
 					sinon.assert.calledTwice( autosave.adapter.save );
 					sinon.assert.calledTwice( autosave.adapter.save );
@@ -567,7 +567,7 @@ describe( 'Autosave', () => {
 				writer.addMarker( 'marker-affecting-data', { usingOperation: false, affectsData: false, range } );
 				writer.addMarker( 'marker-affecting-data', { usingOperation: false, affectsData: false, range } );
 			} );
 			} );
 
 
-			sandbox.clock.tick( 2000 );
+			sandbox.clock.tick( 1000 );
 
 
 			return runPromiseCycles().then( () => {
 			return runPromiseCycles().then( () => {
 				sinon.assert.calledOnce( autosave.adapter.save );
 				sinon.assert.calledOnce( autosave.adapter.save );