| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- /**
- * @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': '<meta name=Generator content="Microsoft Word 15">'
- } )
- };
- 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': '<meta name=Generator content="Microsoft Word 15"><p>Foo bar</p>'
- } )
- };
- normalizer.setInputData( data ).exec();
- expect( data.content ).to.be.instanceOf( DocumentFragment );
- } );
- describe( 'activation trigger', () => {
- describe( 'correct markup', () => {
- [
- {
- 'text/html': '<meta name=Generator content="Microsoft Word 15">'
- },
- {
- 'text/html': '<html><head><meta name="Generator" content=Microsoft Word 15></head></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': '<meta name=Generator content="Other">'
- },
- {
- 'text/html': '<p id="docs-internal-guid-12345"></p>'
- }
- ].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;
- } );
- } );
- } );
- } );
- } );
|