/** * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ import { mswordNormalizer as normalizer } from '../../src/normalizers/msword'; import ContentNormalizer from '../../src/contentnormalizer'; import { createDataTransfer } from '../_utils/utils'; import DocumentFragment from '@ckeditor/ckeditor5-engine/src/view/documentfragment'; // Functionality of the msword normalizer is tested with autogenerated normalization tests. describe( 'PasteFromOffice/normalizers/msword', () => { afterEach( () => { normalizer.setInputData( {} ); } ); it( 'should be instance of content normalizers', () => { expect( normalizer ).to.be.instanceOf( ContentNormalizer ); } ); it( 'should mark data as processed', () => { const data = { dataTransfer: createDataTransfer( { 'text/html': '' } ) }; normalizer.setInputData( data ).exec(); expect( data.isTransformedWithPasteFromOffice ).to.be.true; } ); it( 'should not mark non-word data as processed', () => { const data = { dataTransfer: createDataTransfer( { 'text/html': 'foo bar' } ) }; normalizer.setInputData( data ).exec(); expect( data.isTransformedWithPasteFromOffice ).to.be.undefined; } ); it( 'outputs view#documentFragment', () => { const data = { dataTransfer: createDataTransfer( { 'text/html': '
Foo bar
' } ) }; normalizer.setInputData( data ).exec(); expect( data.content ).to.be.instanceOf( DocumentFragment ); } ); describe( 'activation trigger', () => { describe( 'correct markup', () => { [ { 'text/html': '' }, { 'text/html': '' } ].forEach( ( data, index ) => { it( `should be active for markup #${ index }`, () => { expect( normalizer.isActive ).to.be.false; normalizer.setInputData( { dataTransfer: createDataTransfer( data ) } ); expect( normalizer.isActive ).to.be.true; } ); } ); } ); describe( 'wrong markup', () => { [ { 'text/html': '' }, { 'text/html': '' } ].forEach( ( data, index ) => { it( `should be not active for wrong markup #${ index }`, () => { expect( normalizer.isActive ).to.be.false; normalizer.setInputData( { dataTransfer: createDataTransfer( data ) } ); expect( normalizer.isActive ).to.be.false; } ); } ); } ); } ); } );