|
|
@@ -92,7 +92,7 @@ export function assertBinding( observable, stateBefore, data, stateAfter ) {
|
|
|
* have common props (So the watchdog will be able to find the correct editor instance and restart it).
|
|
|
*
|
|
|
* @param {Function} fn Tested function that should throw a `CKEditorError`.
|
|
|
- * @param {RegExp} message Expected message of the error.
|
|
|
+ * @param {RegExp|String} message Expected message of the error.
|
|
|
* @param {*} editorThatShouldBeFindableFromContext An editor instance that should be findable from the error context.
|
|
|
* @param {Object} [data] Error data.
|
|
|
*/
|
|
|
@@ -116,14 +116,17 @@ export function expectToThrowCKEditorError( fn, message, editorThatShouldBeFinda
|
|
|
* find the correct editor instance and restart it).
|
|
|
*
|
|
|
* @param {module:utils/ckeditorerror~CKEditorError} err The tested error.
|
|
|
- * @param {RegExp} message Expected message of the error.
|
|
|
+ * @param {RegExp|String} message Expected message of the error.
|
|
|
* @param {*} [editorThatShouldBeFindableFromContext] An editor instance that should be findable from the error context.
|
|
|
* @param {Object} [data] Error data.
|
|
|
*/
|
|
|
export function assertCKEditorError( err, message, editorThatShouldBeFindableFromContext, data ) {
|
|
|
- expect( err ).to.be.instanceOf( CKEditorError );
|
|
|
- expect( message ).to.be.a( 'regexp', `Error message should be a string. Got ${ typeof message }.` );
|
|
|
+ if ( typeof message === 'string' ) {
|
|
|
+ message = new RegExp( message );
|
|
|
+ }
|
|
|
|
|
|
+ expect( message ).to.be.a( 'regexp', 'Error message should be a string or a regexp.' );
|
|
|
+ expect( err ).to.be.instanceOf( CKEditorError );
|
|
|
expect( err.message ).to.match( message, 'Error message does not match the provided one.' );
|
|
|
|
|
|
// TODO: The `editorThatShouldBeFindableFromContext` is optional but should be required in the future.
|