|
|
@@ -1042,58 +1042,4 @@ describe( 'Element', () => {
|
|
|
);
|
|
|
} );
|
|
|
} );
|
|
|
-
|
|
|
- describe( 'createFromDefinition()', () => {
|
|
|
- it( 'should create element from definition without any attributes', () => {
|
|
|
- const el = Element.createFromDefinition( { name: 'p' } );
|
|
|
-
|
|
|
- expect( el ).to.be.an.instanceof( Node );
|
|
|
- expect( el ).to.have.property( 'name' ).that.equals( 'p' );
|
|
|
- expect( el ).to.have.property( 'parent' ).that.is.null;
|
|
|
- expect( count( el.getAttributeKeys() ) ).to.equal( 0 );
|
|
|
- } );
|
|
|
-
|
|
|
- it( 'should create element from definition with attributes as plain object', () => {
|
|
|
- const el = Element.createFromDefinition( { name: 'p', attribute: { foo: 'bar' } } );
|
|
|
-
|
|
|
- expect( el ).to.have.property( 'name' ).that.equals( 'p' );
|
|
|
- expect( count( el.getAttributeKeys() ) ).to.equal( 1 );
|
|
|
- expect( el.getAttribute( 'foo' ) ).to.equal( 'bar' );
|
|
|
- } );
|
|
|
-
|
|
|
- it( 'should create element from definition with classes as single string', () => {
|
|
|
- const el = Element.createFromDefinition( { name: 'p', attribute: { id: 'test' }, class: 'foo-bar' } );
|
|
|
-
|
|
|
- expect( el._attrs.has( 'class' ) ).to.be.false;
|
|
|
- expect( el._attrs.has( 'id' ) ).to.be.true;
|
|
|
- expect( el._classes.has( 'foo-bar' ) ).to.be.true;
|
|
|
- } );
|
|
|
-
|
|
|
- it( 'should create element from definition with classes set as array', () => {
|
|
|
- const el = Element.createFromDefinition( { name: 'p', attribute: { id: 'test' }, class: [ 'one', 'two', 'three' ] } );
|
|
|
-
|
|
|
- expect( el._attrs.has( 'class' ) ).to.be.false;
|
|
|
- expect( el._attrs.has( 'id' ) ).to.be.true;
|
|
|
- expect( el._classes.has( 'one' ) ).to.be.true;
|
|
|
- expect( el._classes.has( 'two' ) ).to.be.true;
|
|
|
- expect( el._classes.has( 'three' ) ).to.be.true;
|
|
|
- } );
|
|
|
-
|
|
|
- it( 'should create element from definition with style object', () => {
|
|
|
- const el = Element.createFromDefinition( {
|
|
|
- name: 'p',
|
|
|
- attribute: { id: 'test' },
|
|
|
- style: { one: 'style1', two: 'style2', three: 'url(http://ckeditor.com)' }
|
|
|
- } );
|
|
|
-
|
|
|
- expect( el._attrs.has( 'style' ) ).to.be.false;
|
|
|
- expect( el._attrs.has( 'id' ) ).to.be.true;
|
|
|
- expect( el._styles.has( 'one' ) ).to.be.true;
|
|
|
- expect( el._styles.get( 'one' ) ).to.equal( 'style1' );
|
|
|
- expect( el._styles.has( 'two' ) ).to.be.true;
|
|
|
- expect( el._styles.get( 'two' ) ).to.equal( 'style2' );
|
|
|
- expect( el._styles.has( 'three' ) ).to.be.true;
|
|
|
- expect( el._styles.get( 'three' ) ).to.equal( 'url(http://ckeditor.com)' );
|
|
|
- } );
|
|
|
- } );
|
|
|
} );
|