|
|
@@ -8,7 +8,6 @@ import utilsTestUtils from '/tests/utils/_utils/utils.js';
|
|
|
import ObservableMixin from '/ckeditor5/utils/observablemixin.js';
|
|
|
import EmitterMixin from '/ckeditor5/utils/emittermixin.js';
|
|
|
import EventInfo from '/ckeditor5/utils/eventinfo.js';
|
|
|
-import CKEditorError from '/ckeditor5/utils/ckeditorerror.js';
|
|
|
import mix from '/ckeditor5/utils/mix.js';
|
|
|
|
|
|
const assertBinding = utilsTestUtils.assertBinding;
|
|
|
@@ -146,7 +145,7 @@ describe( 'Observable', () => {
|
|
|
|
|
|
expect( () => {
|
|
|
car.set( 'normalProperty', 2 );
|
|
|
- } ).to.throw( CKEditorError, /^observable-set-cannot-override/ );
|
|
|
+ } ).to.throwCKEditorError( /^observable-set-cannot-override/ );
|
|
|
|
|
|
expect( car ).to.have.property( 'normalProperty', 1 );
|
|
|
} );
|
|
|
@@ -160,7 +159,7 @@ describe( 'Observable', () => {
|
|
|
|
|
|
expect( () => {
|
|
|
car.set( 'method', 2 );
|
|
|
- } ).to.throw( CKEditorError, /^observable-set-cannot-override/ );
|
|
|
+ } ).to.throwCKEditorError( /^observable-set-cannot-override/ );
|
|
|
|
|
|
expect( car.method ).to.be.a( 'function' );
|
|
|
} );
|
|
|
@@ -198,28 +197,28 @@ describe( 'Observable', () => {
|
|
|
it( 'should throw when attributes are not strings', () => {
|
|
|
expect( () => {
|
|
|
car.bind();
|
|
|
- } ).to.throw( CKEditorError, /observable-bind-wrong-attrs/ );
|
|
|
+ } ).to.throwCKEditorError( /observable-bind-wrong-attrs/ );
|
|
|
|
|
|
expect( () => {
|
|
|
car.bind( new Date() );
|
|
|
- } ).to.throw( CKEditorError, /observable-bind-wrong-attrs/ );
|
|
|
+ } ).to.throwCKEditorError( /observable-bind-wrong-attrs/ );
|
|
|
|
|
|
expect( () => {
|
|
|
car.bind( 'color', new Date() );
|
|
|
- } ).to.throw( CKEditorError, /observable-bind-wrong-attrs/ );
|
|
|
+ } ).to.throwCKEditorError( /observable-bind-wrong-attrs/ );
|
|
|
} );
|
|
|
|
|
|
it( 'should throw when the same attribute is used than once', () => {
|
|
|
expect( () => {
|
|
|
car.bind( 'color', 'color' );
|
|
|
- } ).to.throw( CKEditorError, /observable-bind-duplicate-attrs/ );
|
|
|
+ } ).to.throwCKEditorError( /observable-bind-duplicate-attrs/ );
|
|
|
} );
|
|
|
|
|
|
it( 'should throw when binding the same attribute more than once', () => {
|
|
|
expect( () => {
|
|
|
car.bind( 'color' );
|
|
|
car.bind( 'color' );
|
|
|
- } ).to.throw( CKEditorError, /observable-bind-rebind/ );
|
|
|
+ } ).to.throwCKEditorError( /observable-bind-rebind/ );
|
|
|
} );
|
|
|
|
|
|
describe( 'to', () => {
|
|
|
@@ -234,7 +233,7 @@ describe( 'Observable', () => {
|
|
|
car = new Car();
|
|
|
|
|
|
car.bind( 'color' ).to();
|
|
|
- } ).to.throw( CKEditorError, /observable-bind-to-parse-error/ );
|
|
|
+ } ).to.throwCKEditorError( /observable-bind-to-parse-error/ );
|
|
|
} );
|
|
|
|
|
|
it( 'should throw when binding multiple attributes to multiple observables', () => {
|
|
|
@@ -244,31 +243,31 @@ describe( 'Observable', () => {
|
|
|
|
|
|
expect( () => {
|
|
|
vehicle.bind( 'color', 'year' ).to( car1, 'color', car2, 'year' );
|
|
|
- } ).to.throw( CKEditorError, /observable-bind-to-no-callback/ );
|
|
|
+ } ).to.throwCKEditorError( /observable-bind-to-no-callback/ );
|
|
|
|
|
|
expect( () => {
|
|
|
vehicle = new Car();
|
|
|
|
|
|
vehicle.bind( 'color', 'year' ).to( car1, car2 );
|
|
|
- } ).to.throw( CKEditorError, /observable-bind-to-no-callback/ );
|
|
|
+ } ).to.throwCKEditorError( /observable-bind-to-no-callback/ );
|
|
|
|
|
|
expect( () => {
|
|
|
vehicle = new Car();
|
|
|
|
|
|
vehicle.bind( 'color', 'year' ).to( car1, car2, 'year' );
|
|
|
- } ).to.throw( CKEditorError, /observable-bind-to-no-callback/ );
|
|
|
+ } ).to.throwCKEditorError( /observable-bind-to-no-callback/ );
|
|
|
|
|
|
expect( () => {
|
|
|
vehicle = new Car();
|
|
|
|
|
|
vehicle.bind( 'color', 'year' ).to( car1, 'color', car2 );
|
|
|
- } ).to.throw( CKEditorError, /observable-bind-to-no-callback/ );
|
|
|
+ } ).to.throwCKEditorError( /observable-bind-to-no-callback/ );
|
|
|
|
|
|
expect( () => {
|
|
|
vehicle = new Car();
|
|
|
|
|
|
vehicle.bind( 'color', 'year', 'custom' ).to( car, car );
|
|
|
- } ).to.throw( CKEditorError, /observable-bind-to-no-callback/ );
|
|
|
+ } ).to.throwCKEditorError( /observable-bind-to-no-callback/ );
|
|
|
} );
|
|
|
|
|
|
it( 'should throw when binding multiple attributes but passed a callback', () => {
|
|
|
@@ -276,13 +275,13 @@ describe( 'Observable', () => {
|
|
|
|
|
|
expect( () => {
|
|
|
vehicle.bind( 'color', 'year' ).to( car, () => {} );
|
|
|
- } ).to.throw( CKEditorError, /observable-bind-to-extra-callback/ );
|
|
|
+ } ).to.throwCKEditorError( /observable-bind-to-extra-callback/ );
|
|
|
|
|
|
expect( () => {
|
|
|
vehicle = new Car();
|
|
|
|
|
|
vehicle.bind( 'color', 'year' ).to( car, car, () => {} );
|
|
|
- } ).to.throw( CKEditorError, /observable-bind-to-extra-callback/ );
|
|
|
+ } ).to.throwCKEditorError( /observable-bind-to-extra-callback/ );
|
|
|
} );
|
|
|
|
|
|
it( 'should throw when binding a single attribute but multiple callbacks', () => {
|
|
|
@@ -290,13 +289,13 @@ describe( 'Observable', () => {
|
|
|
|
|
|
expect( () => {
|
|
|
vehicle.bind( 'color' ).to( car, () => {}, () => {} );
|
|
|
- } ).to.throw( CKEditorError, /observable-bind-to-parse-error/ );
|
|
|
+ } ).to.throwCKEditorError( /observable-bind-to-parse-error/ );
|
|
|
|
|
|
expect( () => {
|
|
|
vehicle = new Car();
|
|
|
|
|
|
vehicle.bind( 'color' ).to( car, car, () => {}, () => {} );
|
|
|
- } ).to.throw( CKEditorError, /observable-bind-to-parse-error/ );
|
|
|
+ } ).to.throwCKEditorError( /observable-bind-to-parse-error/ );
|
|
|
} );
|
|
|
|
|
|
it( 'should throw when a number of attributes does not match', () => {
|
|
|
@@ -304,25 +303,25 @@ describe( 'Observable', () => {
|
|
|
|
|
|
expect( () => {
|
|
|
vehicle.bind( 'color' ).to( car, 'color', 'year' );
|
|
|
- } ).to.throw( CKEditorError, /observable-bind-to-attrs-length/ );
|
|
|
+ } ).to.throwCKEditorError( /observable-bind-to-attrs-length/ );
|
|
|
|
|
|
expect( () => {
|
|
|
vehicle = new Car();
|
|
|
|
|
|
vehicle.bind( 'color', 'year' ).to( car, 'color' );
|
|
|
- } ).to.throw( CKEditorError, /observable-bind-to-attrs-length/ );
|
|
|
+ } ).to.throwCKEditorError( /observable-bind-to-attrs-length/ );
|
|
|
|
|
|
expect( () => {
|
|
|
vehicle = new Car();
|
|
|
|
|
|
vehicle.bind( 'color' ).to( car, 'color', 'year', () => {} );
|
|
|
- } ).to.throw( CKEditorError, /observable-bind-to-attrs-length/ );
|
|
|
+ } ).to.throwCKEditorError( /observable-bind-to-attrs-length/ );
|
|
|
|
|
|
expect( () => {
|
|
|
vehicle = new Car();
|
|
|
|
|
|
vehicle.bind( 'color' ).to( car, 'color', car, 'color', 'year', () => {} );
|
|
|
- } ).to.throw( CKEditorError, /observable-bind-to-attrs-length/ );
|
|
|
+ } ).to.throwCKEditorError( /observable-bind-to-attrs-length/ );
|
|
|
} );
|
|
|
|
|
|
it( 'should work when attributes don\'t exist in to() observable #1', () => {
|
|
|
@@ -739,7 +738,7 @@ describe( 'Observable', () => {
|
|
|
it( 'should throw when non-string attribute is passed', () => {
|
|
|
expect( () => {
|
|
|
car.unbind( new Date() );
|
|
|
- } ).to.throw( CKEditorError, /observable-unbind-wrong-attrs/ );
|
|
|
+ } ).to.throwCKEditorError( /observable-unbind-wrong-attrs/ );
|
|
|
} );
|
|
|
|
|
|
it( 'should remove all bindings', () => {
|