/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.
*/
import normalizeClipboardData from '../../src/utils/normalizeclipboarddata';
describe( 'normalizeClipboardData()', () => {
it( 'should strip all span.Apple-converted-space', () => {
expect( normalizeClipboardData(
' \t\nx\u00a0\u00a0'
) ).to.equal( ' \t\nx\u00a0\u00a0' );
} );
it( 'should replace span.Apple-converted-space of length one with a normal space', () => {
expect(
normalizeClipboardData( ' x\u00a0' )
).to.equal( ' x ' );
} );
it( 'should strip all spans with no attributes', () => {
expect( normalizeClipboardData(
' \t\nx\u00a0\u00a0'
) ).to.equal( ' \t\nx\u00a0\u00a0' );
} );
it( 'should replace spans with no attributes with a normal space', () => {
expect(
normalizeClipboardData( ' x\u00a0' )
).to.equal( ' x ' );
} );
it( 'should not strip spans with no attributes if they contain anything but spaces', () => {
expect(
normalizeClipboardData( ' axb\u00a0xc' )
).to.equal( ' axb\u00a0xc' );
} );
it( 'should not replace spans of length 1+ with normal space', () => {
expect(
normalizeClipboardData( ' x\u00a0 x\u00a0\u00a0x \u00a0' )
).to.equal( ' x\u00a0 x\u00a0\u00a0x \u00a0' );
} );
it( 'should not strip spans with any attribute (except span.Apple-converted-space)', () => {
const input =
' x' +
'\u00a0x' +
' x' +
'\u00a0';
expect( normalizeClipboardData( input ) ).to.equal( input );
} );
it( 'should not be greedy', () => {
expect(
normalizeClipboardData( ' a' )
).to.equal( ' a' );
} );
} );