8
0

upcastwriter.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. import DocumentFragment from '../../src/view/documentfragment';
  6. import Element from '../../src/view/element';
  7. import Text from '../../src/view/text';
  8. import UpcastWriter from '../../src/view/upcastwriter';
  9. import HtmlDataProcessor from '../../src/dataprocessor/htmldataprocessor';
  10. import ViewPosition from '../../src/view/position';
  11. import ViewRange from '../../src/view/range';
  12. import ViewSelection from '../../src/view/selection';
  13. import Document from '../../src/view/document';
  14. describe( 'UpcastWriter', () => {
  15. let writer, view, dataprocessor, document;
  16. before( () => {
  17. document = new Document();
  18. writer = new UpcastWriter( document );
  19. dataprocessor = new HtmlDataProcessor();
  20. } );
  21. beforeEach( () => {
  22. const html = '' +
  23. '<h1 style="color:blue;position:fixed;">Heading <strong>1</strong></h1>' +
  24. '<p class="foo1 bar2" style="text-align:left;" data-attr="abc">Foo <i>Bar</i> <strong>Bold</strong></p>' +
  25. '<p><u>Some underlined</u> text</p>' +
  26. '<ul>' +
  27. '<li class="single">Item 1</li>' +
  28. '<li><span>Item <s>1</s></span></li>' +
  29. '<li><h2>Item 1</h2></li>' +
  30. '</ul>';
  31. view = dataprocessor.toView( html );
  32. } );
  33. describe( 'createDocumentFragment', () => {
  34. it( 'should create empty document fragment', () => {
  35. const df = writer.createDocumentFragment();
  36. expect( df ).to.instanceOf( DocumentFragment );
  37. expect( df.childCount ).to.equal( 0 );
  38. } );
  39. it( 'should create document fragment with children', () => {
  40. const df = writer.createDocumentFragment( [ view.getChild( 0 ), view.getChild( 1 ) ] );
  41. expect( df ).to.instanceOf( DocumentFragment );
  42. expect( df.childCount ).to.equal( 2 );
  43. } );
  44. } );
  45. describe( 'createElement', () => {
  46. it( 'should create empty element', () => {
  47. const el = writer.createElement( 'p' );
  48. expect( el ).to.instanceOf( Element );
  49. expect( el.name ).to.equal( 'p' );
  50. expect( Array.from( el.getAttributes() ).length ).to.equal( 0 );
  51. expect( el.childCount ).to.equal( 0 );
  52. } );
  53. it( 'should create element with attributes', () => {
  54. const el = writer.createElement( 'a', { 'class': 'editor', 'contentEditable': 'true' } );
  55. expect( el ).to.instanceOf( Element );
  56. expect( el.name ).to.equal( 'a' );
  57. expect( Array.from( el.getAttributes() ).length ).to.equal( 2 );
  58. expect( el.childCount ).to.equal( 0 );
  59. } );
  60. it( 'should create element with children', () => {
  61. const el = writer.createElement( 'div', null, [ view.getChild( 0 ) ] );
  62. expect( el ).to.instanceOf( Element );
  63. expect( el.name ).to.equal( 'div' );
  64. expect( Array.from( el.getAttributes() ).length ).to.equal( 0 );
  65. expect( el.childCount ).to.equal( 1 );
  66. } );
  67. it( 'should create element with attributes and children', () => {
  68. const el = writer.createElement( 'blockquote',
  69. { 'class': 'editor', 'contentEditable': 'true' },
  70. view.getChild( 2 ) );
  71. expect( el ).to.instanceOf( Element );
  72. expect( el.name ).to.equal( 'blockquote' );
  73. expect( Array.from( el.getAttributes() ).length ).to.equal( 2 );
  74. expect( el.childCount ).to.equal( 1 );
  75. } );
  76. } );
  77. describe( 'createText', () => {
  78. it( 'should create text', () => {
  79. const text = writer.createText( 'FooBar' );
  80. expect( text ).to.instanceOf( Text );
  81. expect( text.data ).to.equal( 'FooBar' );
  82. } );
  83. } );
  84. describe( 'clone', () => {
  85. it( 'should clone simple element', () => {
  86. const el = view.getChild( 0 );
  87. const clone = writer.clone( el );
  88. expect( clone ).to.not.equal( el );
  89. expect( clone.isSimilar( el ) ).to.true;
  90. expect( clone.childCount ).to.equal( 0 );
  91. } );
  92. it( 'should clone element with all attributes', () => {
  93. const el = view.getChild( 1 );
  94. const clone = writer.clone( el );
  95. expect( clone ).to.not.equal( el );
  96. expect( clone.isSimilar( el ) ).to.true;
  97. expect( clone.childCount ).to.equal( 0 );
  98. } );
  99. it( 'should deep clone element', () => {
  100. const el = view.getChild( 0 );
  101. const clone = writer.clone( el, true );
  102. expect( clone ).to.not.equal( el );
  103. expect( clone.isSimilar( el ) ).to.true;
  104. expect( clone.childCount ).to.equal( el.childCount );
  105. } );
  106. } );
  107. describe( 'appendChild', () => {
  108. it( 'should append inline child to paragraph', () => {
  109. const el = view.getChild( 2 );
  110. const newChild = new Element( 'span' );
  111. const appended = writer.appendChild( newChild, el );
  112. expect( appended ).to.equal( 1 );
  113. expect( newChild.parent ).to.equal( el );
  114. expect( el.childCount ).to.equal( 3 );
  115. } );
  116. it( 'should append block children to paragraph', () => {
  117. const el = view.getChild( 2 );
  118. const newChild1 = new Element( 'p' );
  119. const newChild2 = new Element( 'h2' );
  120. const appended = writer.appendChild( [ newChild1, newChild2 ], el );
  121. expect( appended ).to.equal( 2 );
  122. expect( newChild1.parent ).to.equal( el );
  123. expect( newChild2.parent ).to.equal( el );
  124. expect( el.childCount ).to.equal( 4 );
  125. } );
  126. it( 'should append list item to the list', () => {
  127. const el = view.getChild( 3 );
  128. const newChild = new Element( 'li' );
  129. const appended = writer.appendChild( newChild, el );
  130. expect( appended ).to.equal( 1 );
  131. expect( newChild.parent ).to.equal( el );
  132. expect( el.childCount ).to.equal( 4 );
  133. } );
  134. it( 'should append element to DocumentFragment element', () => {
  135. const newChild = new Element( 'p' );
  136. const appended = writer.appendChild( newChild, view );
  137. expect( appended ).to.equal( 1 );
  138. expect( newChild.parent ).to.equal( view );
  139. expect( view.childCount ).to.equal( 5 );
  140. } );
  141. } );
  142. describe( 'insertChild', () => {
  143. it( 'should insert inline child into the paragraph on the first position', () => {
  144. const el = view.getChild( 2 );
  145. const newChild = new Element( 'span' );
  146. const inserted = writer.insertChild( 0, newChild, el );
  147. expect( inserted ).to.equal( 1 );
  148. expect( newChild.parent ).to.equal( el );
  149. expect( el.getChild( 0 ) ).to.equal( newChild );
  150. expect( el.childCount ).to.equal( 3 );
  151. } );
  152. it( 'should insert block children into the paragraph on the last position', () => {
  153. const el = view.getChild( 2 );
  154. const newChild1 = new Element( 'blockquote' );
  155. const newChild2 = new Element( 'h2' );
  156. const inserted = writer.insertChild( 2, [ newChild1, newChild2 ], el );
  157. expect( inserted ).to.equal( 2 );
  158. expect( newChild1.parent ).to.equal( el );
  159. expect( newChild2.parent ).to.equal( el );
  160. expect( el.getChild( 2 ) ).to.equal( newChild1 );
  161. expect( el.getChild( 3 ) ).to.equal( newChild2 );
  162. expect( el.childCount ).to.equal( 4 );
  163. } );
  164. it( 'should insert list item into the list element', () => {
  165. const el = view.getChild( 3 );
  166. const newChild = new Element( 'li' );
  167. const inserted = writer.insertChild( 1, newChild, el );
  168. expect( inserted ).to.equal( 1 );
  169. expect( newChild.parent ).to.equal( el );
  170. expect( el.getChild( 1 ) ).to.equal( newChild );
  171. expect( el.childCount ).to.equal( 4 );
  172. } );
  173. it( 'should insert element to DocumentFragment element', () => {
  174. const newChild = new Element( 'p' );
  175. const inserted = writer.insertChild( 4, newChild, view );
  176. expect( inserted ).to.equal( 1 );
  177. expect( newChild.parent ).to.equal( view );
  178. expect( view.getChild( 4 ) ).to.equal( newChild );
  179. expect( view.childCount ).to.equal( 5 );
  180. } );
  181. } );
  182. describe( 'removeChildren', () => {
  183. it( 'should remove child from the beginning of the paragraph', () => {
  184. const el = view.getChild( 1 );
  185. const toRemove = el.getChild( 0 );
  186. const removed = writer.removeChildren( 0, 1, el );
  187. expect( removed.length ).to.equal( 1 );
  188. expect( removed[ 0 ] ).to.equal( toRemove );
  189. expect( el.childCount ).to.equal( 3 );
  190. } );
  191. it( 'should remove two last list items from the list element', () => {
  192. const el = view.getChild( 3 );
  193. const toRemove1 = el.getChild( 1 );
  194. const toRemove2 = el.getChild( 2 );
  195. const removed = writer.removeChildren( 1, 2, el );
  196. expect( removed.length ).to.equal( 2 );
  197. expect( removed[ 0 ] ).to.equal( toRemove1 );
  198. expect( removed[ 1 ] ).to.equal( toRemove2 );
  199. expect( el.childCount ).to.equal( 1 );
  200. } );
  201. it( 'should remove child from DocumentFragment element', () => {
  202. const toRemove = view.getChild( 2 );
  203. const removed = writer.removeChildren( 2, 1, view );
  204. expect( removed.length ).to.equal( 1 );
  205. expect( removed[ 0 ] ).to.equal( toRemove );
  206. expect( view.childCount ).to.equal( 3 );
  207. } );
  208. } );
  209. describe( 'remove', () => {
  210. it( 'should remove list item from the list element', () => {
  211. const toRemove = view.getChild( 3 ).getChild( 1 );
  212. const removed = writer.remove( toRemove );
  213. expect( removed.length ).to.equal( 1 );
  214. expect( removed[ 0 ] ).to.equal( toRemove );
  215. expect( view.getChild( 3 ).childCount ).to.equal( 2 );
  216. } );
  217. it( 'should have no effect on detached elements', () => {
  218. const newChild = new Element( 'h2' );
  219. const removed = writer.remove( newChild );
  220. expect( removed.length ).to.equal( 0 );
  221. expect( view.childCount ).to.equal( 4 );
  222. } );
  223. it( 'should remove direct root (DocumentFragment) child', () => {
  224. const toRemove = view.getChild( 3 );
  225. const removed = writer.remove( toRemove );
  226. expect( removed.length ).to.equal( 1 );
  227. expect( removed[ 0 ] ).to.equal( toRemove );
  228. expect( view.childCount ).to.equal( 3 );
  229. } );
  230. } );
  231. describe( 'replace', () => {
  232. it( 'should replace single element', () => {
  233. const el = view.getChild( 0 ).getChild( 1 );
  234. const newChild = new Element( 'span' );
  235. const replacement = writer.replace( el, newChild );
  236. expect( replacement ).to.true;
  237. expect( view.getChild( 0 ).getChild( 1 ) ).to.equal( newChild );
  238. expect( view.getChild( 0 ).childCount ).to.equal( 2 );
  239. } );
  240. it( 'should replace element with children', () => {
  241. const el = view.getChild( 3 );
  242. const newChild = new Element( 'ol' );
  243. const replacement = writer.replace( el, newChild );
  244. expect( replacement ).to.true;
  245. expect( view.getChild( 3 ) ).to.equal( newChild );
  246. expect( view.childCount ).to.equal( 4 );
  247. } );
  248. it( 'should have no effect on detached elements', () => {
  249. const oldChild = new Element( 'h2' );
  250. const newChild = new Element( 'h2' );
  251. const replacement = writer.replace( oldChild, newChild );
  252. expect( replacement ).to.false;
  253. expect( view.childCount ).to.equal( 4 );
  254. } );
  255. } );
  256. describe( 'unwrapElement', () => {
  257. it( 'should unwrap simple element', () => {
  258. const documentFragment = dataprocessor.toView( '<ul><li><p>foo</p></li></ul>' );
  259. const paragraph = documentFragment.getChild( 0 ).getChild( 0 ).getChild( 0 );
  260. writer.unwrapElement( paragraph );
  261. expect( dataprocessor.toData( documentFragment ) ).to.equal( '<ul><li>foo</li></ul>' );
  262. } );
  263. it( 'should unwrap element with children', () => {
  264. const documentFragment = dataprocessor.toView(
  265. '<p><span style="color:red"><strong>foo</strong><a href="example.com">example</a>bar</span></p>' );
  266. const span = documentFragment.getChild( 0 ).getChild( 0 );
  267. writer.unwrapElement( span );
  268. expect( dataprocessor.toData( documentFragment ) ).to.equal(
  269. '<p><strong>foo</strong><a href="example.com">example</a>bar</p>' );
  270. } );
  271. it( 'should do nothing for elements without parent', () => {
  272. const element = new Element( document, 'p', null, 'foo' );
  273. writer.unwrapElement( element );
  274. expect( dataprocessor.toData( element ) ).to.equal( '<p>foo</p>' );
  275. } );
  276. } );
  277. describe( 'rename', () => {
  278. it( 'should rename simple element', () => {
  279. const el = view.getChild( 0 ).getChild( 1 );
  280. const renamed = writer.rename( 'i', el );
  281. expect( renamed ).to.not.equal( el );
  282. expect( renamed ).to.equal( view.getChild( 0 ).getChild( 1 ) );
  283. expect( renamed.name ).to.equal( 'i' );
  284. expect( view.getChild( 0 ).childCount ).to.equal( 2 );
  285. } );
  286. it( 'should rename direct root (DocumentFragment) child element', () => {
  287. const el = view.getChild( 1 );
  288. const renamed = writer.rename( 'h3', el );
  289. expect( renamed ).to.not.equal( el );
  290. expect( renamed ).to.equal( view.getChild( 1 ) );
  291. expect( renamed.name ).to.equal( 'h3' );
  292. expect( view.childCount ).to.equal( 4 );
  293. } );
  294. it( 'should have no effect on detached element', () => {
  295. const el = new Element( document, 'h2' );
  296. const renamed = writer.rename( 'h3', el );
  297. expect( renamed ).to.null;
  298. expect( view.childCount ).to.equal( 4 );
  299. } );
  300. } );
  301. describe( 'setAttribute', () => {
  302. it( 'should add new attribute', () => {
  303. const el = view.getChild( 0 );
  304. writer.setAttribute( 'testAttr', 'testVal', el );
  305. expect( el.getAttribute( 'testAttr' ) ).to.equal( 'testVal' );
  306. } );
  307. it( 'should update existing attribute', () => {
  308. const el = view.getChild( 1 );
  309. writer.setAttribute( 'data-attr', 'foo', el );
  310. expect( el.getAttribute( 'data-attr' ) ).to.equal( 'foo' );
  311. } );
  312. } );
  313. describe( 'removeAttribute', () => {
  314. it( 'should remove existing attribute', () => {
  315. const el = view.getChild( 1 );
  316. writer.removeAttribute( 'data-attr', el );
  317. expect( el.hasAttribute( 'data-attr' ) ).to.false;
  318. } );
  319. it( 'should have no effect if attribute does not exists', () => {
  320. const el = view.getChild( 0 );
  321. writer.removeAttribute( 'non-existent', el );
  322. expect( el.hasAttribute( 'non-existent' ) ).to.false;
  323. } );
  324. } );
  325. describe( 'addClass', () => {
  326. it( 'should add new classes if no classes', () => {
  327. const el = view.getChild( 2 );
  328. writer.addClass( [ 'foo', 'bar' ], el );
  329. expect( el.hasClass( 'foo' ) ).to.true;
  330. expect( el.hasClass( 'bar' ) ).to.true;
  331. expect( Array.from( el.getClassNames() ).length ).to.equal( 2 );
  332. } );
  333. it( 'should add new class to existing classes', () => {
  334. const el = view.getChild( 1 );
  335. writer.addClass( 'newClass', el );
  336. expect( el.hasClass( 'newClass' ) ).to.true;
  337. expect( Array.from( el.getClassNames() ).length ).to.equal( 3 );
  338. } );
  339. } );
  340. describe( 'removeClass', () => {
  341. it( 'should remove existing class', () => {
  342. const el = view.getChild( 3 ).getChild( 0 );
  343. writer.removeClass( 'single', el );
  344. expect( el.hasClass( 'single' ) ).to.false;
  345. expect( Array.from( el.getClassNames() ).length ).to.equal( 0 );
  346. } );
  347. it( 'should remove existing class from many classes', () => {
  348. const el = view.getChild( 1 );
  349. writer.removeClass( 'foo1', el );
  350. expect( el.hasClass( 'foo1' ) ).to.false;
  351. expect( el.hasClass( 'bar2' ) ).to.true;
  352. expect( Array.from( el.getClassNames() ).length ).to.equal( 1 );
  353. } );
  354. it( 'should have no effect if there are no classes', () => {
  355. const el = view.getChild( 0 );
  356. writer.removeClass( 'non-existent', el );
  357. expect( el.hasClass( 'non-existent' ) ).to.false;
  358. expect( Array.from( el.getClassNames() ).length ).to.equal( 0 );
  359. } );
  360. } );
  361. describe( 'setStyle', () => {
  362. it( 'should add new style', () => {
  363. const el = view.getChild( 2 );
  364. writer.setStyle( {
  365. color: 'red',
  366. position: 'fixed'
  367. }, el );
  368. expect( el.getStyle( 'color' ) ).to.equal( 'red' );
  369. expect( el.getStyle( 'position' ) ).to.equal( 'fixed' );
  370. expect( Array.from( el.getStyleNames() ).length ).to.equal( 2 );
  371. } );
  372. it( 'should update existing styles', () => {
  373. const el = view.getChild( 1 );
  374. writer.setStyle( 'text-align', 'center', el );
  375. expect( el.getStyle( 'text-align' ) ).to.equal( 'center' );
  376. expect( Array.from( el.getStyleNames() ).length ).to.equal( 1 );
  377. } );
  378. } );
  379. describe( 'removeStyle', () => {
  380. it( 'should remove existing style', () => {
  381. const el = view.getChild( 0 );
  382. writer.removeStyle( [ 'color', 'position' ], el );
  383. expect( el.hasStyle( 'color' ) ).to.be.false;
  384. expect( el.hasStyle( 'position' ) ).to.be.false;
  385. expect( Array.from( el.getStyleNames() ).length ).to.equal( 0 );
  386. } );
  387. it( 'should remove value from existing styles', () => {
  388. const el = view.getChild( 0 );
  389. writer.removeStyle( 'position', el );
  390. expect( el.hasStyle( 'color' ) ).to.true;
  391. expect( el.hasStyle( 'position' ) ).to.false;
  392. expect( Array.from( el.getStyleNames() ).length ).to.equal( 1 );
  393. } );
  394. it( 'should have no effect if styles does not exists', () => {
  395. const el = view.getChild( 2 );
  396. writer.removeStyle( [ 'color', 'position' ], el );
  397. expect( el.hasStyle( 'color' ) ).to.false;
  398. expect( el.hasStyle( 'position' ) ).to.false;
  399. expect( Array.from( el.getStyleNames() ).length ).to.equal( 0 );
  400. } );
  401. } );
  402. describe( 'setCustomProperty', () => {
  403. it( 'should add or update custom property', () => {
  404. const el = new Element( 'span' );
  405. writer.setCustomProperty( 'prop1', 'foo', el );
  406. writer.setCustomProperty( 'prop2', 'bar', el );
  407. expect( el.getCustomProperty( 'prop1' ) ).to.equal( 'foo' );
  408. expect( el.getCustomProperty( 'prop2' ) ).to.equal( 'bar' );
  409. expect( Array.from( el.getCustomProperties() ).length ).to.equal( 2 );
  410. const objectProperty = { foo: 'bar' };
  411. writer.setCustomProperty( 'prop2', objectProperty, el );
  412. expect( el.getCustomProperty( 'prop1' ) ).to.equal( 'foo' );
  413. expect( el.getCustomProperty( 'prop2' ) ).to.equal( objectProperty );
  414. expect( Array.from( el.getCustomProperties() ).length ).to.equal( 2 );
  415. } );
  416. } );
  417. describe( 'removeCustomProperty', () => {
  418. it( 'should remove existing custom property', () => {
  419. const el = new Element( 'p' );
  420. writer.setCustomProperty( 'prop1', 'foo', el );
  421. expect( el.getCustomProperty( 'prop1' ) ).to.equal( 'foo' );
  422. expect( Array.from( el.getCustomProperties() ).length ).to.equal( 1 );
  423. writer.removeCustomProperty( 'prop1', el );
  424. expect( el.getCustomProperty( 'prop1' ) ).to.undefined;
  425. expect( Array.from( el.getCustomProperties() ).length ).to.equal( 0 );
  426. } );
  427. it( 'should have no effect if custom property does not exists', () => {
  428. const el = new Element( 'h1' );
  429. writer.removeCustomProperty( 'prop1', el );
  430. expect( el.getCustomProperty( 'prop1' ) ).to.undefined;
  431. expect( Array.from( el.getCustomProperties() ).length ).to.equal( 0 );
  432. } );
  433. } );
  434. describe( 'createPositionAt()', () => {
  435. it( 'should return instance of Position', () => {
  436. const span = new Element( document, 'span' );
  437. expect( writer.createPositionAt( span, 0 ) ).to.be.instanceof( ViewPosition );
  438. } );
  439. } );
  440. describe( 'createPositionAfter()', () => {
  441. it( 'should return instance of Position', () => {
  442. const span = new Element( document, 'span', undefined, new Element( document, 'span' ) );
  443. expect( writer.createPositionAfter( span.getChild( 0 ) ) ).to.be.instanceof( ViewPosition );
  444. } );
  445. } );
  446. describe( 'createPositionBefore()', () => {
  447. it( 'should return instance of Position', () => {
  448. const span = new Element( document, 'span', undefined, new Element( document, 'span' ) );
  449. expect( writer.createPositionBefore( span.getChild( 0 ) ) ).to.be.instanceof( ViewPosition );
  450. } );
  451. } );
  452. describe( 'createRange()', () => {
  453. it( 'should return instance of Range', () => {
  454. expect( writer.createRange( writer.createPositionAt( new Element( document, 'span' ), 0 ) ) ).to.be.instanceof( ViewRange );
  455. } );
  456. } );
  457. describe( 'createRangeIn()', () => {
  458. it( 'should return instance of Range', () => {
  459. const span = new Element( document, 'span', undefined, new Element( document, 'span' ) );
  460. expect( writer.createRangeIn( span.getChild( 0 ) ) ).to.be.instanceof( ViewRange );
  461. } );
  462. } );
  463. describe( 'createRangeOn()', () => {
  464. it( 'should return instance of Range', () => {
  465. const span = new Element( document, 'span', undefined, new Element( document, 'span' ) );
  466. expect( writer.createRangeOn( span.getChild( 0 ) ) ).to.be.instanceof( ViewRange );
  467. } );
  468. } );
  469. describe( 'createSelection()', () => {
  470. it( 'should return instance of Selection', () => {
  471. expect( writer.createSelection() ).to.be.instanceof( ViewSelection );
  472. } );
  473. } );
  474. } );