upcastwriter.js 19 KB

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