model-selection-to-view-converters.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import ModelDocument from '../../src/model/document';
  6. import ModelElement from '../../src/model/element';
  7. import ModelRange from '../../src/model/range';
  8. import ModelPosition from '../../src/model/position';
  9. import ViewDocument from '../../src/view/document';
  10. import ViewContainerElement from '../../src/view/containerelement';
  11. import ViewAttributeElement from '../../src/view/attributeelement';
  12. import { mergeAttributes } from '../../src/view/writer';
  13. import Mapper from '../../src/conversion/mapper';
  14. import ModelConversionDispatcher from '../../src/conversion/modelconversiondispatcher';
  15. import {
  16. convertRangeSelection,
  17. convertCollapsedSelection,
  18. convertSelectionAttribute,
  19. convertSelectionMarker,
  20. clearAttributes,
  21. clearFakeSelection
  22. } from '../../src/conversion/model-selection-to-view-converters';
  23. import {
  24. insertElement,
  25. insertText,
  26. wrapItem,
  27. wrapRange,
  28. unwrapRange
  29. } from '../../src/conversion/model-to-view-converters';
  30. import { stringify as stringifyView } from '../../src/dev-utils/view';
  31. import { setData as setModelData } from '../../src/dev-utils/model';
  32. const spanViewElementForMarker = new ViewAttributeElement( 'span' );
  33. spanViewElementForMarker.priority = 1;
  34. describe( 'model-selection-to-view-converters', () => {
  35. let dispatcher, mapper;
  36. let modelDoc, modelRoot, modelSelection;
  37. let viewDoc, viewRoot, viewSelection;
  38. beforeEach( () => {
  39. modelDoc = new ModelDocument();
  40. modelRoot = modelDoc.createRoot();
  41. modelSelection = modelDoc.selection;
  42. modelDoc.schema.allow( { name: '$text', inside: '$root' } );
  43. viewDoc = new ViewDocument();
  44. viewRoot = viewDoc.createRoot( 'div' );
  45. viewSelection = viewDoc.selection;
  46. mapper = new Mapper();
  47. mapper.bindElements( modelRoot, viewRoot );
  48. dispatcher = new ModelConversionDispatcher( { mapper, viewSelection } );
  49. dispatcher.on( 'insert:$text', insertText() );
  50. dispatcher.on( 'addAttribute:bold', wrapItem( new ViewAttributeElement( 'strong' ) ) );
  51. dispatcher.on( 'addMarker:marker', wrapRange( spanViewElementForMarker ) );
  52. dispatcher.on( 'removeMarker:marker', unwrapRange( spanViewElementForMarker ) );
  53. // Default selection converters.
  54. dispatcher.on( 'selection', clearAttributes(), { priority: 'low' } );
  55. dispatcher.on( 'selection', convertRangeSelection(), { priority: 'low' } );
  56. dispatcher.on( 'selection', convertCollapsedSelection(), { priority: 'low' } );
  57. } );
  58. afterEach( () => {
  59. viewDoc.destroy();
  60. } );
  61. describe( 'default converters', () => {
  62. beforeEach( () => {
  63. // Selection converters for selection attributes.
  64. dispatcher.on( 'selectionAttribute:bold', convertSelectionAttribute( new ViewAttributeElement( 'strong' ) ) );
  65. dispatcher.on( 'selectionAttribute:italic', convertSelectionAttribute( new ViewAttributeElement( 'em' ) ) );
  66. dispatcher.on( 'selectionMarker:marker', convertSelectionMarker( spanViewElementForMarker ) );
  67. } );
  68. describe( 'range selection', () => {
  69. it( 'in same container', () => {
  70. test(
  71. [ 1, 4 ],
  72. 'foobar',
  73. 'f{oob}ar'
  74. );
  75. } );
  76. it( 'in same container with unicode characters', () => {
  77. test(
  78. [ 2, 6 ],
  79. 'நிலைக்கு',
  80. 'நி{லைக்}கு'
  81. );
  82. } );
  83. it( 'in same container, over attribute', () => {
  84. test(
  85. [ 1, 5 ],
  86. 'fo<$text bold="true">ob</$text>ar',
  87. 'f{o<strong>ob</strong>a}r'
  88. );
  89. } );
  90. it( 'in same container, next to attribute', () => {
  91. test(
  92. [ 1, 2 ],
  93. 'fo<$text bold="true">ob</$text>ar',
  94. 'f{o}<strong>ob</strong>ar'
  95. );
  96. } );
  97. it( 'in same attribute', () => {
  98. test(
  99. [ 2, 4 ],
  100. 'f<$text bold="true">ooba</$text>r',
  101. 'f<strong>o{ob}a</strong>r'
  102. );
  103. } );
  104. it( 'in same attribute, selection same as attribute', () => {
  105. test(
  106. [ 2, 4 ],
  107. 'fo<$text bold="true">ob</$text>ar',
  108. 'fo{<strong>ob</strong>}ar'
  109. );
  110. } );
  111. it( 'starts in text node, ends in attribute #1', () => {
  112. test(
  113. [ 1, 3 ],
  114. 'fo<$text bold="true">ob</$text>ar',
  115. 'f{o<strong>o}b</strong>ar'
  116. );
  117. } );
  118. it( 'starts in text node, ends in attribute #2', () => {
  119. test(
  120. [ 1, 4 ],
  121. 'fo<$text bold="true">ob</$text>ar',
  122. 'f{o<strong>ob</strong>}ar'
  123. );
  124. } );
  125. it( 'starts in attribute, ends in text node', () => {
  126. test(
  127. [ 3, 5 ],
  128. 'fo<$text bold="true">ob</$text>ar',
  129. 'fo<strong>o{b</strong>a}r'
  130. );
  131. } );
  132. it( 'consumes consumable values properly', () => {
  133. // Add callback that will fire before default ones.
  134. // This should prevent default callback doing anything.
  135. dispatcher.on( 'selection', ( evt, data, consumable ) => {
  136. expect( consumable.consume( data.selection, 'selection' ) ).to.be.true;
  137. }, { priority: 'high' } );
  138. // Similar test case as the first in this suite.
  139. test(
  140. [ 1, 4 ],
  141. 'foobar',
  142. 'foobar' // No selection in view.
  143. );
  144. } );
  145. it( 'should convert backward selection', () => {
  146. test(
  147. [ 1, 3, 'backward' ],
  148. 'foobar',
  149. 'f{oo}bar'
  150. );
  151. expect( viewSelection.focus.offset ).to.equal( 1 );
  152. } );
  153. } );
  154. describe( 'collapsed selection', () => {
  155. it( 'in container', () => {
  156. test(
  157. [ 1, 1 ],
  158. 'foobar',
  159. 'f{}oobar'
  160. );
  161. } );
  162. it( 'in attribute', () => {
  163. test(
  164. [ 3, 3 ],
  165. 'f<$text bold="true">ooba</$text>r',
  166. 'f<strong>oo{}ba</strong>r'
  167. );
  168. } );
  169. it( 'in container with extra attributes', () => {
  170. test(
  171. [ 1, 1 ],
  172. 'foobar',
  173. 'f<em>[]</em>oobar',
  174. { italic: true }
  175. );
  176. } );
  177. it( 'in attribute with extra attributes', () => {
  178. test(
  179. [ 3, 3 ],
  180. 'f<$text bold="true">ooba</$text>r',
  181. 'f<strong>oo</strong><em><strong>[]</strong></em><strong>ba</strong>r',
  182. { italic: true }
  183. );
  184. } );
  185. it( 'in attribute and marker', () => {
  186. setModelData( modelDoc, 'fo<$text bold="true">ob</$text>ar' );
  187. const marker = modelDoc.markers.set( 'marker', ModelRange.createFromParentsAndOffsets( modelRoot, 1, modelRoot, 5 ) );
  188. modelSelection.setRanges( [ new ModelRange( ModelPosition.createAt( modelRoot, 3 ) ) ] );
  189. // Update selection attributes according to model.
  190. modelSelection.refresh();
  191. // Remove view children manually (without firing additional conversion).
  192. viewRoot.removeChildren( 0, viewRoot.childCount );
  193. // Convert model to view.
  194. dispatcher.convertInsertion( ModelRange.createIn( modelRoot ) );
  195. dispatcher.convertMarker( 'addMarker', marker.name, marker.getRange() );
  196. dispatcher.convertSelection( modelSelection );
  197. // Stringify view and check if it is same as expected.
  198. expect( stringifyView( viewRoot, viewSelection, { showType: false } ) )
  199. .to.equal( '<div>f<span>o<strong>o{}b</strong>a</span>r</div>' );
  200. } );
  201. it( 'in attribute and marker - no attribute', () => {
  202. setModelData( modelDoc, 'fo<$text bold="true">ob</$text>ar' );
  203. const marker = modelDoc.markers.set( 'marker', ModelRange.createFromParentsAndOffsets( modelRoot, 1, modelRoot, 5 ) );
  204. modelSelection.setRanges( [ new ModelRange( ModelPosition.createAt( modelRoot, 3 ) ) ] );
  205. // Update selection attributes according to model.
  206. modelSelection.refresh();
  207. modelSelection.removeAttribute( 'bold' );
  208. // Remove view children manually (without firing additional conversion).
  209. viewRoot.removeChildren( 0, viewRoot.childCount );
  210. // Convert model to view.
  211. dispatcher.convertInsertion( ModelRange.createIn( modelRoot ) );
  212. dispatcher.convertMarker( 'addMarker', marker.name, marker.getRange() );
  213. dispatcher.convertSelection( modelSelection );
  214. // Stringify view and check if it is same as expected.
  215. expect( stringifyView( viewRoot, viewSelection, { showType: false } ) )
  216. .to.equal( '<div>f<span>o<strong>o</strong>[]<strong>b</strong>a</span>r</div>' );
  217. } );
  218. it( 'in marker - using view element as element creator function for selection marker conversion', () => {
  219. dispatcher.on( 'selectionMarker:marker2', convertSelectionMarker(
  220. ( data ) => new ViewAttributeElement( 'span', { 'class': data.name } )
  221. ) );
  222. setModelData( modelDoc, 'foobar' );
  223. const marker = modelDoc.markers.set( 'marker2', ModelRange.createFromParentsAndOffsets( modelRoot, 1, modelRoot, 5 ) );
  224. modelSelection.setRanges( [ new ModelRange( ModelPosition.createAt( modelRoot, 3 ) ) ] );
  225. // Remove view children manually (without firing additional conversion).
  226. viewRoot.removeChildren( 0, viewRoot.childCount );
  227. // Convert model to view.
  228. dispatcher.convertInsertion( ModelRange.createIn( modelRoot ) );
  229. dispatcher.convertMarker( 'addMarker', marker.name, marker.getRange() );
  230. dispatcher.convertSelection( modelSelection );
  231. // Stringify view and check if it is same as expected.
  232. expect( stringifyView( viewRoot, viewSelection, { showType: false } ) )
  233. .to.equal( '<div>foo<span class="marker2">[]</span>bar</div>' );
  234. } );
  235. it( 'consumes consumable values properly', () => {
  236. // Add callbacks that will fire before default ones.
  237. // This should prevent default callbacks doing anything.
  238. dispatcher.on( 'selection', ( evt, data, consumable ) => {
  239. expect( consumable.consume( data.selection, 'selection' ) ).to.be.true;
  240. }, { priority: 'high' } );
  241. dispatcher.on( 'selectionAttribute:bold', ( evt, data, consumable ) => {
  242. expect( consumable.consume( data.selection, 'selectionAttribute:bold' ) ).to.be.true;
  243. }, { priority: 'high' } );
  244. // Similar test case as above.
  245. test(
  246. [ 3, 3 ],
  247. 'f<$text bold="true">ooba</$text>r',
  248. 'f<strong>ooba</strong>r' // No selection in view.
  249. );
  250. } );
  251. } );
  252. } );
  253. describe( 'clean-up', () => {
  254. describe( 'convertRangeSelection', () => {
  255. it( 'should remove all ranges before adding new range', () => {
  256. test(
  257. [ 0, 2 ],
  258. 'foobar',
  259. '{fo}obar'
  260. );
  261. test(
  262. [ 3, 5 ],
  263. 'foobar',
  264. 'foo{ba}r'
  265. );
  266. expect( viewSelection.rangeCount ).to.equal( 1 );
  267. } );
  268. } );
  269. describe( 'convertCollapsedSelection', () => {
  270. it( 'should remove all ranges before adding new range', () => {
  271. test(
  272. [ 2, 2 ],
  273. 'foobar',
  274. 'fo{}obar'
  275. );
  276. test(
  277. [ 3, 3 ],
  278. 'foobar',
  279. 'foo{}bar'
  280. );
  281. expect( viewSelection.rangeCount ).to.equal( 1 );
  282. } );
  283. } );
  284. describe( 'clearAttributes', () => {
  285. it( 'should remove all ranges before adding new range', () => {
  286. dispatcher.on( 'selectionAttribute:bold', convertSelectionAttribute( new ViewAttributeElement( 'b' ) ) );
  287. dispatcher.on( 'addAttribute:style', wrapItem( new ViewAttributeElement( 'b' ) ) );
  288. test(
  289. [ 3, 3 ],
  290. 'foobar',
  291. 'foo<b>[]</b>bar',
  292. { bold: 'true' }
  293. );
  294. const modelRange = ModelRange.createFromParentsAndOffsets( modelRoot, 1, modelRoot, 1 );
  295. modelDoc.selection.setRanges( [ modelRange ] );
  296. dispatcher.convertSelection( modelDoc.selection );
  297. expect( viewSelection.rangeCount ).to.equal( 1 );
  298. const viewString = stringifyView( viewRoot, viewSelection, { showType: false } );
  299. expect( viewString ).to.equal( '<div>f{}oobar</div>' );
  300. } );
  301. it( 'should do nothing if the attribute element had been already removed', () => {
  302. dispatcher.on( 'selectionAttribute:bold', convertSelectionAttribute( new ViewAttributeElement( 'b' ) ) );
  303. dispatcher.on( 'addAttribute:style', wrapItem( new ViewAttributeElement( 'b' ) ) );
  304. test(
  305. [ 3, 3 ],
  306. 'foobar',
  307. 'foo<b>[]</b>bar',
  308. { bold: 'true' }
  309. );
  310. // Remove <b></b> manually.
  311. mergeAttributes( viewSelection.getFirstPosition() );
  312. const modelRange = ModelRange.createFromParentsAndOffsets( modelRoot, 1, modelRoot, 1 );
  313. modelDoc.selection.setRanges( [ modelRange ] );
  314. dispatcher.convertSelection( modelDoc.selection );
  315. expect( viewSelection.rangeCount ).to.equal( 1 );
  316. const viewString = stringifyView( viewRoot, viewSelection, { showType: false } );
  317. expect( viewString ).to.equal( '<div>f{}oobar</div>' );
  318. } );
  319. } );
  320. describe( 'clearFakeSelection', () => {
  321. it( 'should clear fake selection', () => {
  322. dispatcher.on( 'selection', clearFakeSelection() );
  323. viewSelection.setFake( true );
  324. dispatcher.convertSelection( modelSelection );
  325. expect( viewSelection.isFake ).to.be.false;
  326. } );
  327. } );
  328. } );
  329. describe( 'using element creator for attributes conversion', () => {
  330. beforeEach( () => {
  331. function themeElementCreator( themeValue ) {
  332. if ( themeValue == 'important' ) {
  333. return new ViewAttributeElement( 'strong', { style: 'text-transform:uppercase;' } );
  334. } else if ( themeValue == 'gold' ) {
  335. return new ViewAttributeElement( 'span', { style: 'color:yellow;' } );
  336. }
  337. }
  338. dispatcher.on( 'selectionAttribute:theme', convertSelectionAttribute( themeElementCreator ) );
  339. dispatcher.on( 'addAttribute:theme', wrapItem( themeElementCreator ) );
  340. dispatcher.on( 'selectionAttribute:italic', convertSelectionAttribute( new ViewAttributeElement( 'em' ) ) );
  341. } );
  342. describe( 'range selection', () => {
  343. it( 'in same container, over attribute', () => {
  344. test(
  345. [ 1, 5 ],
  346. 'fo<$text theme="gold">ob</$text>ar',
  347. 'f{o<span style="color:yellow;">ob</span>a}r'
  348. );
  349. } );
  350. it( 'in same attribute', () => {
  351. test(
  352. [ 2, 4 ],
  353. 'f<$text theme="gold">ooba</$text>r',
  354. 'f<span style="color:yellow;">o{ob}a</span>r'
  355. );
  356. } );
  357. it( 'in same attribute, selection same as attribute', () => {
  358. test(
  359. [ 2, 4 ],
  360. 'fo<$text theme="important">ob</$text>ar',
  361. 'fo{<strong style="text-transform:uppercase;">ob</strong>}ar'
  362. );
  363. } );
  364. it( 'starts in attribute, ends in text node', () => {
  365. test(
  366. [ 3, 5 ],
  367. 'fo<$text theme="important">ob</$text>ar',
  368. 'fo<strong style="text-transform:uppercase;">o{b</strong>a}r'
  369. );
  370. } );
  371. } );
  372. describe( 'collapsed selection', () => {
  373. it( 'in attribute', () => {
  374. test(
  375. [ 3, 3 ],
  376. 'f<$text theme="gold">ooba</$text>r',
  377. 'f<span style="color:yellow;">oo{}ba</span>r'
  378. );
  379. } );
  380. it( 'in container with theme attribute', () => {
  381. test(
  382. [ 1, 1 ],
  383. 'foobar',
  384. 'f<strong style="text-transform:uppercase;">[]</strong>oobar',
  385. { theme: 'important' }
  386. );
  387. } );
  388. it( 'in theme attribute with extra attributes #1', () => {
  389. test(
  390. [ 3, 3 ],
  391. 'f<$text theme="gold">ooba</$text>r',
  392. 'f<span style="color:yellow;">oo</span>' +
  393. '<em><span style="color:yellow;">[]</span></em>' +
  394. '<span style="color:yellow;">ba</span>r',
  395. { italic: true }
  396. );
  397. } );
  398. it( 'in theme attribute with extra attributes #2', () => {
  399. // In contrary to test above, we don't have strong + span on the selection.
  400. // This is because strong and span are both created by the same attribute.
  401. // Since style="important" overwrites style="gold" on selection, we have only strong element.
  402. // In example above, selection has both style and italic attribute.
  403. test(
  404. [ 3, 3 ],
  405. 'f<$text theme="gold">ooba</$text>r',
  406. 'f<span style="color:yellow;">oo</span>' +
  407. '<strong style="text-transform:uppercase;">[]</strong>' +
  408. '<span style="color:yellow;">ba</span>r',
  409. { theme: 'important' }
  410. );
  411. } );
  412. } );
  413. } );
  414. describe( 'table cell selection converter', () => {
  415. beforeEach( () => {
  416. modelDoc.schema.registerItem( 'table' );
  417. modelDoc.schema.registerItem( 'tr' );
  418. modelDoc.schema.registerItem( 'td' );
  419. modelDoc.schema.allow( { name: 'table', inside: '$root' } );
  420. modelDoc.schema.allow( { name: 'tr', inside: 'table' } );
  421. modelDoc.schema.allow( { name: 'td', inside: 'tr' } );
  422. modelDoc.schema.allow( { name: '$text', inside: 'td' } );
  423. // "Universal" converter to convert table structure.
  424. const tableConverter = insertElement( ( data ) => new ViewContainerElement( data.item.name ) );
  425. dispatcher.on( 'insert:table', tableConverter );
  426. dispatcher.on( 'insert:tr', tableConverter );
  427. dispatcher.on( 'insert:td', tableConverter );
  428. // Special converter for table cells.
  429. dispatcher.on( 'selection', ( evt, data, consumable, conversionApi ) => {
  430. const selection = data.selection;
  431. if ( !consumable.test( selection, 'selection' ) || selection.isCollapsed ) {
  432. return;
  433. }
  434. for ( let range of selection.getRanges() ) {
  435. const node = range.start.nodeAfter;
  436. if ( node == range.end.nodeBefore && node instanceof ModelElement && node.name == 'td' ) {
  437. consumable.consume( selection, 'selection' );
  438. let viewNode = conversionApi.mapper.toViewElement( node );
  439. viewNode.addClass( 'selected' );
  440. }
  441. }
  442. } );
  443. } );
  444. it( 'should not be used to convert selection that is not on table cell', () => {
  445. test(
  446. [ 1, 5 ],
  447. 'f{o<$text bold="true">ob</$text>a}r',
  448. 'f{o<strong>ob</strong>a}r'
  449. );
  450. } );
  451. it( 'should add a class to the selected table cell', () => {
  452. test(
  453. // table tr#0 |td#0, table tr#0 td#0|
  454. [ [ 0, 0, 0 ], [ 0, 0, 1 ] ],
  455. '<table><tr><td>foo</td></tr><tr><td>bar</td></tr></table>',
  456. '<table><tr><td class="selected">foo</td></tr><tr><td>bar</td></tr></table>'
  457. );
  458. } );
  459. it( 'should not be used if selection contains more than just a table cell', () => {
  460. test(
  461. // table tr td#1, table tr#2
  462. [ [ 0, 0, 0, 1 ], [ 0, 0, 2 ] ],
  463. '<table><tr><td>foo</td><td>bar</td></tr></table>',
  464. '<table><tr><td>f{oo</td><td>bar</td>]</tr></table>'
  465. );
  466. } );
  467. } );
  468. // Tests if the selection got correctly converted.
  469. // Because `setData` might use selection converters itself to set the selection, we can't use it
  470. // to set the selection (because then we would test converters using converters).
  471. // Instead, the `test` function expects to be passed `selectionPaths` which is an array containing two numbers or two arrays,
  472. // that are offsets or paths of selection positions in root element.
  473. function test( selectionPaths, modelInput, expectedView, selectionAttributes = {} ) {
  474. // Parse passed `modelInput` string and set it as current model.
  475. setModelData( modelDoc, modelInput );
  476. // Manually set selection ranges using passed `selectionPaths`.
  477. const startPath = typeof selectionPaths[ 0 ] == 'number' ? [ selectionPaths[ 0 ] ] : selectionPaths[ 0 ];
  478. const endPath = typeof selectionPaths[ 1 ] == 'number' ? [ selectionPaths[ 1 ] ] : selectionPaths[ 1 ];
  479. const startPos = new ModelPosition( modelRoot, startPath );
  480. const endPos = new ModelPosition( modelRoot, endPath );
  481. const isBackward = selectionPaths[ 2 ] === 'backward';
  482. modelSelection.setRanges( [ new ModelRange( startPos, endPos ) ], isBackward );
  483. // Update selection attributes according to model.
  484. modelSelection.refresh();
  485. // And add or remove passed attributes.
  486. for ( let key in selectionAttributes ) {
  487. let value = selectionAttributes[ key ];
  488. if ( value ) {
  489. modelSelection.setAttribute( key, value );
  490. } else {
  491. modelSelection.removeAttribute( key );
  492. }
  493. }
  494. // Remove view children manually (without firing additional conversion).
  495. viewRoot.removeChildren( 0, viewRoot.childCount );
  496. // Convert model to view.
  497. dispatcher.convertInsertion( ModelRange.createIn( modelRoot ) );
  498. dispatcher.convertSelection( modelSelection );
  499. // Stringify view and check if it is same as expected.
  500. expect( stringifyView( viewRoot, viewSelection, { showType: false } ) ).to.equal( '<div>' + expectedView + '</div>' );
  501. }
  502. } );