Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Tests: Added unit test making sure that fake selection is still being…
Browse files Browse the repository at this point in the history
… correctly mapped, even if reused.
  • Loading branch information
mlewand committed Sep 16, 2019
1 parent dbe93b2 commit 0f547e1
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tests/view/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Renderer from '../../src/view/renderer';
import DocumentFragment from '../../src/view/documentfragment';
import DowncastWriter from '../../src/view/downcastwriter';

import { parse, setData as setViewData, getData as getViewData } from '../../src/dev-utils/view';
import { parse, stringify, setData as setViewData, getData as getViewData } from '../../src/dev-utils/view';
import { INLINE_FILLER, INLINE_FILLER_LENGTH, isBlockFiller, BR_FILLER } from '../../src/view/filler';
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
import createViewRoot from './_utils/createroot';
Expand Down Expand Up @@ -1848,6 +1848,25 @@ describe( 'Renderer', () => {

expect( createRangeSpy.callCount ).to.be.equal( 2 );
} );

it( 'correctly maps fake selection ', () => {
// See https://github.com/ckeditor/ckeditor5-engine/pull/1792#issuecomment-529814641
const label = 'subsequent fake selection calls';
const { view: newParagraph, selection: newSelection } = parse( '<container:p>[baz]</container:p>' );

viewRoot._appendChild( newParagraph );

selection._setTo( selection.getRanges(), { fake: true, label } );
renderer.render();

selection._setTo( newSelection.getRanges(), { fake: true, label } );
renderer.render();

const fakeSelectionContainer = domRoot.childNodes[ 1 ];
const mappedSelection = renderer.domConverter.fakeSelectionToView( fakeSelectionContainer );

expect( stringify( viewRoot, mappedSelection ) ).to.be.equal( '<div><p>foo bar</p><p>[baz]</p></div>' );
} );
} );

it( 'should render &nbsp; if no selection label is provided', () => {
Expand Down

0 comments on commit 0f547e1

Please sign in to comment.