/** * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md. */ /* bender-tags: browser-only */ /* globals window */ import XmlDataProcessor from '/ckeditor5/engine/dataprocessor/xmldataprocessor.js'; import xssTemplates from '/tests/engine/dataprocessor/_utils/xsstemplates.js'; import ViewDocumentFragment from '/ckeditor5/engine/view/documentfragment.js'; import { stringify, parse } from '/ckeditor5/engine/dev-utils/view.js'; describe( 'XmlDataProcessor', () => { let dataProcessor; beforeEach( () => { dataProcessor = new XmlDataProcessor(); } ); describe( 'toView', () => { it( 'should return empty DocumentFragment when empty string is passed', () => { const fragment = dataProcessor.toView( '' ); expect( fragment ).to.be.an.instanceOf( ViewDocumentFragment ); expect( fragment.childCount ).to.equal( 0 ); } ); it( 'should convert XML to DocumentFragment with single text node', () => { const fragment = dataProcessor.toView( 'foo bar' ); expect( stringify( fragment ) ).to.equal( 'foo bar' ); } ); it( 'should convert HTML to DocumentFragment with multiple child nodes', () => { const fragment = dataProcessor.toView( '
foo
bar
' ); expect( stringify( fragment ) ).to.equal( 'foo
bar
' ); } ); it( 'should not add any additional nodes', () => { const fragment = dataProcessor.toView( 'foo bar text' ); expect( stringify( fragment ) ).to.equal( 'foo bar text' ); } ); it( 'should allow to use registered namespaces', () => { dataProcessor = new XmlDataProcessor( { namespaces: [ 'foo', 'bar' ] } ); const fragment = dataProcessor.toView( 'foo
bar
' ); expect( dataProcessor.toData( fragment ) ).to.equal( 'foo
bar
' ); } ); } ); } );