|
|
@@ -39,26 +39,24 @@ describe( 'ComponentFactory', () => {
|
|
|
} );
|
|
|
|
|
|
describe( 'add()', () => {
|
|
|
- it( 'throws when trying to override already registered component', () => {
|
|
|
- factory.add( 'foo', () => {} );
|
|
|
+ it( 'does not normalize component names', () => {
|
|
|
+ factory.add( 'FoO', () => {} );
|
|
|
|
|
|
- expectToThrowCKEditorError( () => {
|
|
|
- factory.add( 'foo', () => {} );
|
|
|
- }, /^componentfactory-item-exists/, editor );
|
|
|
+ expect( Array.from( factory.names() ) ).to.have.members( [ 'FoO' ] );
|
|
|
} );
|
|
|
|
|
|
- it( 'throws when trying to override already registered component added with different case', () => {
|
|
|
- factory.add( 'Foo', () => {} );
|
|
|
+ it( 'should allow overriding already registered components', () => {
|
|
|
+ factory.add( 'foo', () => 'old' );
|
|
|
+ factory.add( 'foo', () => 'new' );
|
|
|
|
|
|
- expectToThrowCKEditorError( () => {
|
|
|
- factory.add( 'foo', () => {} );
|
|
|
- }, /^componentfactory-item-exists/, editor );
|
|
|
+ expect( factory.create( 'foo' ) ).to.equal( 'new' );
|
|
|
} );
|
|
|
|
|
|
- it( 'does not normalize component names', () => {
|
|
|
- factory.add( 'FoO', () => {} );
|
|
|
+ it( 'should allow overriding already registered components (same name, different case)', () => {
|
|
|
+ factory.add( 'foo', () => 'old' );
|
|
|
+ factory.add( 'Foo', () => 'new' );
|
|
|
|
|
|
- expect( Array.from( factory.names() ) ).to.have.members( [ 'FoO' ] );
|
|
|
+ expect( factory.create( 'foo' ) ).to.equal( 'new' );
|
|
|
} );
|
|
|
} );
|
|
|
|