Browse Source

Simplified tests.

Maciej Bukowski 6 years ago
parent
commit
a8ea98de87
1 changed files with 8 additions and 20 deletions
  1. 8 20
      packages/ckeditor5-watchdog/tests/watchdog.js

+ 8 - 20
packages/ckeditor5-watchdog/tests/watchdog.js

@@ -177,9 +177,7 @@ describe( 'Watchdog', () => {
 			window.onerror = undefined;
 			window.onerror = undefined;
 
 
 			return watchdog.create( document.createElement( 'div' ) ).then( () => {
 			return watchdog.create( document.createElement( 'div' ) ).then( () => {
-				setTimeout( () => {
-					throw new CKEditorError( 'foo', undefined, watchdog.editor );
-				} );
+				setTimeout( () => throwCKEditorError( 'foo', watchdog.editor ) );
 
 
 				return new Promise( res => {
 				return new Promise( res => {
 					watchdog.on( 'restart', () => {
 					watchdog.on( 'restart', () => {
@@ -203,9 +201,7 @@ describe( 'Watchdog', () => {
 			window.onerror = windowErrorSpy;
 			window.onerror = windowErrorSpy;
 
 
 			return watchdog.create( document.createElement( 'div' ) ).then( () => {
 			return watchdog.create( document.createElement( 'div' ) ).then( () => {
-				setTimeout( () => {
-					throw new CKEditorError( 'foo', undefined, watchdog.editor );
-				} );
+				setTimeout( () => throwCKEditorError( 'foo', watchdog.editor ) );
 
 
 				return new Promise( res => {
 				return new Promise( res => {
 					watchdog.on( 'restart', () => {
 					watchdog.on( 'restart', () => {
@@ -231,9 +227,7 @@ describe( 'Watchdog', () => {
 			window.onerror = undefined;
 			window.onerror = undefined;
 
 
 			return watchdog.create( document.createElement( 'div' ) ).then( () => {
 			return watchdog.create( document.createElement( 'div' ) ).then( () => {
-				setTimeout( () => {
-					throw new CKEditorError( 'foo', undefined, watchdog.editor );
-				} );
+				setTimeout( () => throwCKEditorError( 'foo', watchdog.editor ) );
 
 
 				return new Promise( res => {
 				return new Promise( res => {
 					watchdog.on( 'restart', () => {
 					watchdog.on( 'restart', () => {
@@ -300,9 +294,7 @@ describe( 'Watchdog', () => {
 					watchdog1.on( 'restart', watchdog1ErrorSpy );
 					watchdog1.on( 'restart', watchdog1ErrorSpy );
 					watchdog2.on( 'restart', watchdog2ErrorSpy );
 					watchdog2.on( 'restart', watchdog2ErrorSpy );
 
 
-					setTimeout( () => {
-						throw new CKEditorError( 'foo', undefined, watchdog2.editor );
-					} );
+					setTimeout( () => throwCKEditorError( 'foo', watchdog2.editor ) );
 
 
 					// TODO - timing.
 					// TODO - timing.
 					setTimeout( () => {
 					setTimeout( () => {
@@ -329,9 +321,7 @@ describe( 'Watchdog', () => {
 			window.onerror = undefined;
 			window.onerror = undefined;
 
 
 			return watchdog.create( document.createElement( 'div' ) ).then( () => {
 			return watchdog.create( document.createElement( 'div' ) ).then( () => {
-				setTimeout( () => {
-					throw new CKEditorError( 'foo', undefined, watchdog.editor.model.document );
-				} );
+				setTimeout( () => throwCKEditorError( 'foo', watchdog.editor.model.document ) );
 
 
 				return new Promise( res => {
 				return new Promise( res => {
 					watchdog.on( 'restart', () => {
 					watchdog.on( 'restart', () => {
@@ -354,9 +344,7 @@ describe( 'Watchdog', () => {
 			window.onerror = undefined;
 			window.onerror = undefined;
 
 
 			return watchdog.create( document.createElement( 'div' ) ).then( () => {
 			return watchdog.create( document.createElement( 'div' ) ).then( () => {
-				setTimeout( () => {
-					throw new CKEditorError( 'foo', undefined, { foo: [ 1, 2, 3, { bar: watchdog.editor } ] } );
-				} );
+				setTimeout( () => throwCKEditorError( 'foo', { foo: [ 1, 2, 3, { bar: watchdog.editor } ] } ) );
 
 
 				return new Promise( res => {
 				return new Promise( res => {
 					watchdog.on( 'restart', () => {
 					watchdog.on( 'restart', () => {
@@ -580,7 +568,7 @@ describe( 'Watchdog', () => {
 			const originalErrorHandler = window.onerror;
 			const originalErrorHandler = window.onerror;
 			window.onerror = undefined;
 			window.onerror = undefined;
 
 
-			const consoleErrorStub = sinon.stub( console, 'error' );
+			sinon.stub( console, 'error' );
 
 
 			return watchdog.create( document.createElement( 'div' ), {
 			return watchdog.create( document.createElement( 'div' ), {
 				initialData: '<p>foo</p>',
 				initialData: '<p>foo</p>',
@@ -606,7 +594,7 @@ describe( 'Watchdog', () => {
 						expect( watchdog.editor.getData() ).to.equal( '<p>foo</p>' );
 						expect( watchdog.editor.getData() ).to.equal( '<p>foo</p>' );
 
 
 						sinon.assert.calledWith(
 						sinon.assert.calledWith(
-							consoleErrorStub,
+							console.error,
 							editorGetDataError,
 							editorGetDataError,
 							'An error happened during restoring editor data. Editor will be restored from the previously saved data.'
 							'An error happened during restoring editor data. Editor will be restored from the previously saved data.'
 						);
 						);