8
0
Quellcode durchsuchen

Added test for the Watchdog abstract class.

Maciej Bukowski vor 6 Jahren
Ursprung
Commit
2ff0bfcd83

+ 7 - 0
packages/ckeditor5-watchdog/src/watchdog.js

@@ -96,6 +96,13 @@ export default class Watchdog {
 			}
 		};
 
+		if ( !this._restart ) {
+			throw new Error(
+				'The Watchdog class was split into the abstract `Watchdog` class and the `EditorWatchdog` class. ' +
+				'Please, use `EditorWatchdog` if you have used the `Watchdog` class previously.'
+			);
+		}
+
 		/**
 		 * The creation method.
 		 *

+ 27 - 0
packages/ckeditor5-watchdog/tests/watchdog.js

@@ -0,0 +1,27 @@
+/**
+ * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+import Watchdog from '../src/watchdog';
+
+describe( 'Watchdog', () => {
+	it( 'should not be created directly', () => {
+		expect( () => {
+			// eslint-disable-next-line no-unused-vars
+			const watchdog = new Watchdog();
+		} ).to.throw( /Please, use `EditorWatchdog` if you have used the `Watchdog` class previously\./ );
+	} );
+
+	it( 'should be created using the inheritance', () => {
+		class FooWatchdog extends Watchdog {
+			_restart() {}
+			_isErrorComingFromThisInstance() {}
+		}
+
+		expect( () => {
+			// eslint-disable-next-line no-unused-vars
+			const fooWatchdog = new FooWatchdog();
+		} ).to.not.throw();
+	} );
+} );