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

Commit

Permalink
Added tests for the CKEditorError.rethrowUnexpectedError().
Browse files Browse the repository at this point in the history
  • Loading branch information
ma2ciek committed Oct 8, 2019
1 parent 438819a commit bf36157
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/ckeditorerror.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import { default as CKEditorError, DOCUMENTATION_URL } from '../src/ckeditorerror';
import { expectToThrowCKEditorError } from './_utils/utils';

describe( 'CKEditorError', () => {
it( 'inherits from Error', () => {
Expand Down Expand Up @@ -88,4 +89,30 @@ describe( 'CKEditorError', () => {
expect( ( !!regularError.is && regularError.is( 'CKEditorError' ) ) ).to.be.false;
} );
} );

describe( 'static rethrowUnexpectedError()', () => {
it( 'should rethrow the original CKEditorError as it is', () => {
const ckeditorError = new CKEditorError( 'foo', null );

expectToThrowCKEditorError( () => {
CKEditorError.rethrowUnexpectedError( ckeditorError, {} );
}, /foo/, null );
} );

it( 'should rethrow an unexpected error wrapped in CKEditorError', () => {
const error = new Error( 'foo' );
error.stack = 'bar';
const context = {};

expectToThrowCKEditorError( () => {
CKEditorError.rethrowUnexpectedError( error, context );
}, /unexpected-error/, context, {
originalError: {
message: 'foo',
stack: 'bar',
name: 'Error'
}
} );
} );
} );
} );

0 comments on commit bf36157

Please sign in to comment.