8
0

ckeditorerror.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. 'use strict';
  6. import CKEditorError from '/ckeditor5/utils/ckeditorerror.js';
  7. describe( 'CKEditorError', () => {
  8. it( 'inherits from Error', () => {
  9. let error = new CKEditorError( 'foo' );
  10. expect( error ).to.be.an.instanceOf( Error );
  11. expect( error ).to.be.an.instanceOf( CKEditorError );
  12. } );
  13. it( 'sets the name', () => {
  14. let error = new CKEditorError( 'foo' );
  15. expect( error ).to.have.property( 'name', 'CKEditorError' );
  16. } );
  17. it( 'sets the message', () => {
  18. let error = new CKEditorError( 'foo' );
  19. expect( error ).to.have.property( 'message', 'foo' );
  20. expect( error.data ).to.be.undefined;
  21. } );
  22. it( 'sets the message and data', () => {
  23. let data = { bar: 1 };
  24. let error = new CKEditorError( 'foo', data );
  25. expect( error ).to.have.property( 'message', 'foo {"bar":1}' );
  26. expect( error ).to.have.property( 'data', data );
  27. } );
  28. it( 'appends stringified data to the message', () => {
  29. class Foo {
  30. constructor() {
  31. this.x = 1;
  32. }
  33. }
  34. let data = {
  35. bar: 'a',
  36. bom: new Foo(),
  37. bim: 10
  38. };
  39. let error = new CKEditorError( 'foo', data );
  40. expect( error ).to.have.property( 'message', 'foo {"bar":"a","bom":{"x":1},"bim":10}' );
  41. expect( error ).to.have.property( 'data', data );
  42. } );
  43. } );