Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it( 'should return null if figcaption\'s parent is not a figure', () => {
const element = new ViewElement( 'figcaption' );
new ViewElement( 'div', null, element ); // eslint-disable-line no-new
expect( matchImageCaption( element ) ).to.be.null;
} );
it( 'should return null if figcaption\'s parent is not a figure', () => {
const element = new ViewElement( 'figcaption' );
new ViewElement( 'div', null, element ); // eslint-disable-line no-new
expect( matchImageCaption( element ) ).to.be.null;
} );
it( 'should return null if parent has no image class', () => {
const element = new ViewElement( 'figcaption' );
new ViewElement( 'figure', null, element ); // eslint-disable-line no-new
expect( matchImageCaption( element ) ).to.be.null;
} );
export default function parseImage( node, event, walker ) {
const image = new ViewElement( 'img', { src: node.destination } );
const figure = new ViewElement( 'figure', { class: 'image' }, image );
const child = node.firstChild;
// Parse text inside image and put it into alt.
if ( child && child.type == 'text' ) {
image.setAttribute( 'alt', child.literal );
walker.resumeAt( child, false );
}
return figure;
}
export default function parseImage( node, event, walker ) {
const image = new ViewElement( 'img', { src: node.destination } );
const figure = new ViewElement( 'figure', { class: 'image' }, image );
const child = node.firstChild;
// Parse text inside image and put it into alt.
if ( child && child.type == 'text' ) {
image.setAttribute( 'alt', child.literal );
walker.resumeAt( child, false );
}
return figure;
}
it( 'should add element\'s label if one is provided as function', () => {
element = new ViewElement( 'div' );
widgetize( element, { label: () => 'foo bar baz label' } );
expect( getLabel( element ) ).to.equal( 'foo bar baz label' );
} );
} );
it( 'should return null if figcaption has no parent', () => {
const element = new ViewElement( 'figcaption' );
expect( matchImageCaption( element ) ).to.be.null;
} );
it( 'should return false for non-widgetized elements', () => {
expect( isWidget( new ViewElement( 'p' ) ) ).to.be.false;
} );
} );
it( 'should allow to set label for element', () => {
const element = new ViewElement( 'p' );
setLabel( element, 'foo bar baz' );
expect( getLabel( element ) ).to.equal( 'foo bar baz' );
} );
it( 'should return empty string for elements without label', () => {
const element = new ViewElement( 'div' );
expect( getLabel( element ) ).to.equal( '' );
} );