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 do nothing with an image when changes are in the other parent', () => {
setData(
view,
'foo<img src="/assets/sample.png">'
);
const viewP = viewRoot.getChild( 0 );
const viewDiv = viewRoot.getChild( 1 );
const mapSpy = sinon.spy( view.domConverter, 'mapViewToDom' );
// Change only the paragraph.
view.change( writer => {
const text = writer.createText( 'foo', { b: true } );
writer.insert( writer.createPositionAt( viewRoot.getChild( 0 ).getChild( 0 ), 0 ), text );
writer.wrap( writer.createRangeOn( text ), writer.createAttributeElement( 'b' ) );
} );
it( 'should not fire `loadImage` event for images removed from document', () => {
const spy = sinon.spy();
viewDocument.on( 'imageLoaded', spy );
setData( view, '<img src="/assets/sample.png">' );
sinon.assert.notCalled( spy );
const img = domRoot.querySelector( 'img' );
setData( view, '' );
img.dispatchEvent( new Event( 'load' ) );
sinon.assert.notCalled( spy );
} );
it( 'should fire `loadImage` event for images in the document that are loaded with a delay', () => {
const spy = sinon.spy();
viewDocument.on( 'imageLoaded', spy );
setData( view, '<img src="/assets/sample.png">' );
sinon.assert.notCalled( spy );
domRoot.querySelector( 'img' ).dispatchEvent( new Event( 'load' ) );
sinon.assert.calledOnce( spy );
} );