datacontroller.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. /**
  2. * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. import Model from '../../src/model/model';
  6. import ModelRange from '../../src/model/range';
  7. import ViewRange from '../../src/view/range';
  8. import DataController from '../../src/controller/datacontroller';
  9. import HtmlDataProcessor from '../../src/dataprocessor/htmldataprocessor';
  10. import ModelDocumentFragment from '../../src/model/documentfragment';
  11. import ViewDocumentFragment from '../../src/view/documentfragment';
  12. import { getData, setData, stringify, parse as parseModel } from '../../src/dev-utils/model';
  13. import { parse as parseView, stringify as stringifyView } from '../../src/dev-utils/view';
  14. import count from '@ckeditor/ckeditor5-utils/src/count';
  15. import UpcastHelpers from '../../src/conversion/upcasthelpers';
  16. import DowncastHelpers from '../../src/conversion/downcasthelpers';
  17. import { expectToThrowCKEditorError } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
  18. describe( 'DataController', () => {
  19. let model, modelDocument, htmlDataProcessor, data, schema, upcastHelpers, downcastHelpers;
  20. beforeEach( () => {
  21. model = new Model();
  22. schema = model.schema;
  23. modelDocument = model.document;
  24. modelDocument.createRoot();
  25. modelDocument.createRoot( '$title', 'title' );
  26. schema.register( '$title', { inheritAllFrom: '$root' } );
  27. htmlDataProcessor = new HtmlDataProcessor();
  28. data = new DataController( model, htmlDataProcessor );
  29. upcastHelpers = new UpcastHelpers( [ data.upcastDispatcher ] );
  30. downcastHelpers = new DowncastHelpers( [ data.downcastDispatcher ] );
  31. } );
  32. describe( 'constructor()', () => {
  33. it( 'works without data processor', () => {
  34. const data = new DataController( model );
  35. expect( data.processor ).to.be.undefined;
  36. } );
  37. } );
  38. describe( 'parse()', () => {
  39. it( 'should set text', () => {
  40. schema.extend( '$text', { allowIn: '$root' } );
  41. const output = data.parse( '<p>foo<b>bar</b></p>' );
  42. expect( output ).to.instanceof( ModelDocumentFragment );
  43. expect( stringify( output ) ).to.equal( 'foobar' );
  44. } );
  45. it( 'should set paragraph', () => {
  46. schema.register( 'paragraph', { inheritAllFrom: '$block' } );
  47. upcastHelpers.elementToElement( { view: 'p', model: 'paragraph' } );
  48. const output = data.parse( '<p>foo<b>bar</b></p>' );
  49. expect( output ).to.instanceof( ModelDocumentFragment );
  50. expect( stringify( output ) ).to.equal( '<paragraph>foobar</paragraph>' );
  51. } );
  52. it( 'should set two paragraphs', () => {
  53. schema.register( 'paragraph', { inheritAllFrom: '$block' } );
  54. upcastHelpers.elementToElement( { view: 'p', model: 'paragraph' } );
  55. const output = data.parse( '<p>foo</p><p>bar</p>' );
  56. expect( output ).to.instanceof( ModelDocumentFragment );
  57. expect( stringify( output ) ).to.equal( '<paragraph>foo</paragraph><paragraph>bar</paragraph>' );
  58. } );
  59. it( 'should set paragraphs with bold', () => {
  60. schema.register( 'paragraph', { inheritAllFrom: '$block' } );
  61. schema.extend( '$text', {
  62. allowAttributes: [ 'bold' ]
  63. } );
  64. upcastHelpers.elementToElement( { view: 'p', model: 'paragraph' } );
  65. upcastHelpers.elementToAttribute( { view: 'strong', model: 'bold' } );
  66. const output = data.parse( '<p>foo<strong>bar</strong></p>' );
  67. expect( output ).to.instanceof( ModelDocumentFragment );
  68. expect( stringify( output ) ).to.equal( '<paragraph>foo<$text bold="true">bar</$text></paragraph>' );
  69. } );
  70. it( 'should parse in the root context by default', () => {
  71. const output = data.parse( 'foo' );
  72. expect( stringify( output ) ).to.equal( '' );
  73. } );
  74. it( 'should accept parsing context', () => {
  75. const output = data.parse( 'foo', [ '$block' ] );
  76. expect( stringify( output ) ).to.equal( 'foo' );
  77. } );
  78. } );
  79. describe( 'toModel()', () => {
  80. beforeEach( () => {
  81. schema.register( 'paragraph', { inheritAllFrom: '$block' } );
  82. upcastHelpers.elementToElement( { view: 'p', model: 'paragraph' } );
  83. } );
  84. it( 'should convert content of an element #1', () => {
  85. const viewElement = parseView( '<p>foo</p>' );
  86. const output = data.toModel( viewElement );
  87. expect( output ).to.instanceof( ModelDocumentFragment );
  88. expect( stringify( output ) ).to.equal( '<paragraph>foo</paragraph>' );
  89. } );
  90. it( 'should convert content of an element #2', () => {
  91. const viewFragment = parseView( '<p>foo</p><p>bar</p>' );
  92. const output = data.toModel( viewFragment );
  93. expect( output ).to.be.instanceOf( ModelDocumentFragment );
  94. expect( stringify( output ) ).to.equal( '<paragraph>foo</paragraph><paragraph>bar</paragraph>' );
  95. } );
  96. it( 'should accept parsing context', () => {
  97. modelDocument.createRoot( 'inlineRoot', 'inlineRoot' );
  98. schema.register( 'inlineRoot' );
  99. schema.extend( '$text', { allowIn: 'inlineRoot' } );
  100. const viewFragment = new ViewDocumentFragment( [ parseView( 'foo' ) ] );
  101. // Model fragment in root.
  102. expect( stringify( data.toModel( viewFragment ) ) ).to.equal( '' );
  103. // Model fragment in inline root.
  104. expect( stringify( data.toModel( viewFragment, [ 'inlineRoot' ] ) ) ).to.equal( 'foo' );
  105. } );
  106. } );
  107. describe( 'init()', () => {
  108. it( 'should be decorated', () => {
  109. const spy = sinon.spy();
  110. data.on( 'init', spy );
  111. data.init( 'foo bar' );
  112. sinon.assert.calledWithExactly( spy, sinon.match.any, [ 'foo bar' ] );
  113. } );
  114. it( 'should fire ready event after init', () => {
  115. const spy = sinon.spy();
  116. data.on( 'ready', spy );
  117. data.init( 'foo bar' );
  118. sinon.assert.called( spy );
  119. } );
  120. it( 'should throw an error when document data is already initialized', () => {
  121. data.init( '<p>Foo</p>' );
  122. expectToThrowCKEditorError( () => {
  123. data.init( '<p>Bar</p>' );
  124. }, /datacontroller-init-document-not-empty:/, model );
  125. } );
  126. it( 'should set data to default main root', () => {
  127. schema.extend( '$text', { allowIn: '$root' } );
  128. data.init( 'foo' );
  129. expect( getData( model, { withoutSelection: true } ) ).to.equal( 'foo' );
  130. } );
  131. it( 'should set data to multiple roots at once', () => {
  132. schema.extend( '$text', { allowIn: '$root' } );
  133. data.init( { main: 'bar', title: 'baz' } );
  134. expect( getData( model, { withoutSelection: true } ) ).to.equal( 'bar' );
  135. expect( getData( model, { withoutSelection: true, rootName: 'title' } ) ).to.equal( 'baz' );
  136. } );
  137. it( 'should get root name as a parameter', () => {
  138. schema.extend( '$text', { allowIn: '$root' } );
  139. data.init( { title: 'foo' } );
  140. expect( getData( model, { withoutSelection: true, rootName: 'title' } ) ).to.equal( 'foo' );
  141. } );
  142. it( 'should create a batch', () => {
  143. schema.extend( '$text', { allowIn: '$root' } );
  144. data.init( 'foo' );
  145. expect( count( modelDocument.history.getOperations() ) ).to.equal( 1 );
  146. } );
  147. it( 'should cause firing change event', () => {
  148. const spy = sinon.spy();
  149. schema.extend( '$text', { allowIn: '$root' } );
  150. model.document.on( 'change', spy );
  151. data.init( 'foo' );
  152. expect( spy.calledOnce ).to.be.true;
  153. } );
  154. it( 'should return a resolved Promise', () => {
  155. const promise = data.init( '<p>Foo</p>' );
  156. expect( promise ).to.be.instanceof( Promise );
  157. return promise;
  158. } );
  159. it( 'should throw an error when non-existent root is used (single)', () => {
  160. expectToThrowCKEditorError( () => {
  161. data.init( { nonexistent: '<p>Bar</p>' } );
  162. }, /^datacontroller-init-non-existent-root:/ );
  163. } );
  164. it( 'should throw an error when non-existent root is used (one of many)', () => {
  165. schema.extend( '$text', { allowIn: '$root' } );
  166. expectToThrowCKEditorError( () => {
  167. data.init( { main: 'bar', nonexistent: '<p>Bar</p>' } );
  168. }, /^datacontroller-init-non-existent-root:/, model );
  169. expect( getData( model, { withoutSelection: true } ) ).to.equal( '' );
  170. } );
  171. } );
  172. describe( 'set()', () => {
  173. it( 'should set data to default main root', () => {
  174. schema.extend( '$text', { allowIn: '$root' } );
  175. data.set( 'foo' );
  176. expect( getData( model, { withoutSelection: true } ) ).to.equal( 'foo' );
  177. } );
  178. it( 'should create a batch', () => {
  179. schema.extend( '$text', { allowIn: '$root' } );
  180. data.set( 'foo' );
  181. expect( count( modelDocument.history.getOperations() ) ).to.equal( 1 );
  182. } );
  183. it( 'should cause firing change event', () => {
  184. const spy = sinon.spy();
  185. schema.extend( '$text', { allowIn: '$root' } );
  186. model.document.on( 'change', spy );
  187. data.set( 'foo' );
  188. expect( spy.calledOnce ).to.be.true;
  189. } );
  190. it( 'should get root name as a parameter', () => {
  191. schema.extend( '$text', { allowIn: '$root' } );
  192. data.set( 'foo' );
  193. data.set( { title: 'Bar' } );
  194. expect( getData( model, { withoutSelection: true, rootName: 'main' } ) ).to.equal( 'foo' );
  195. expect( getData( model, { withoutSelection: true, rootName: 'title' } ) ).to.equal( 'Bar' );
  196. expect( count( modelDocument.history.getOperations() ) ).to.equal( 2 );
  197. } );
  198. it( 'should parse given data before set in a context of correct root', () => {
  199. schema.extend( '$text', { allowIn: '$title', disallowIn: '$root' } );
  200. data.set( 'foo', 'main' );
  201. data.set( { title: 'Bar' } );
  202. expect( getData( model, { withoutSelection: true, rootName: 'main' } ) ).to.equal( '' );
  203. expect( getData( model, { withoutSelection: true, rootName: 'title' } ) ).to.equal( 'Bar' );
  204. expect( count( modelDocument.history.getOperations() ) ).to.equal( 2 );
  205. } );
  206. // This case was added when order of params was different and it really didn't work. Let's keep it
  207. // if anyone will ever try to change this.
  208. it( 'should allow setting empty data', () => {
  209. schema.extend( '$text', { allowIn: '$root' } );
  210. data.set( { title: 'foo' } );
  211. expect( getData( model, { withoutSelection: true, rootName: 'title' } ) ).to.equal( 'foo' );
  212. data.set( { title: '' } );
  213. expect( getData( model, { withoutSelection: true, rootName: 'title' } ) ).to.equal( '' );
  214. } );
  215. it( 'should throw an error when non-existent root is used (single)', () => {
  216. expectToThrowCKEditorError( () => {
  217. data.set( { nonexistent: '<p>Bar</p>' } );
  218. }, /datacontroller-set-non-existent-root:/, model );
  219. } );
  220. it( 'should throw an error when non-existent root is used (one of many) without touching any roots data', () => {
  221. schema.extend( '$text', { allowIn: '$root' } );
  222. data.set( 'foo' );
  223. expectToThrowCKEditorError( () => {
  224. data.set( { main: 'bar', nonexistent: '<p>Bar</p>' } );
  225. }, /datacontroller-set-non-existent-root:/, model );
  226. expect( getData( model, { withoutSelection: true } ) ).to.equal( 'foo' );
  227. } );
  228. // https://github.com/ckeditor/ckeditor5-engine/issues/1721.
  229. it( 'should not throw when setting the data with markers that already exist in the editor', () => {
  230. schema.extend( '$text', { allowIn: '$root' } );
  231. data.set( 'foo' );
  232. downcastHelpers.markerToElement( { model: 'marker', view: 'marker' } );
  233. upcastHelpers.elementToMarker( { view: 'marker', model: 'marker' } );
  234. model.change( writer => {
  235. writer.addMarker( 'marker', { range: writer.createRangeIn( modelDocument.getRoot() ), usingOperation: true } );
  236. } );
  237. expect( () => {
  238. data.set( data.get() );
  239. } ).not.to.throw();
  240. } );
  241. } );
  242. describe( 'get()', () => {
  243. it( 'should get paragraph with text', () => {
  244. schema.register( 'paragraph', { inheritAllFrom: '$block' } );
  245. setData( model, '<paragraph>foo</paragraph>' );
  246. downcastHelpers.elementToElement( { model: 'paragraph', view: 'p' } );
  247. expect( data.get() ).to.equal( '<p>foo</p>' );
  248. expect( data.get( { trim: 'empty' } ) ).to.equal( '<p>foo</p>' );
  249. } );
  250. it( 'should trim empty paragraph by default', () => {
  251. schema.register( 'paragraph', { inheritAllFrom: '$block' } );
  252. setData( model, '<paragraph></paragraph>' );
  253. downcastHelpers.elementToElement( { model: 'paragraph', view: 'p' } );
  254. expect( data.get() ).to.equal( '' );
  255. expect( data.get( { trim: 'empty' } ) ).to.equal( '' );
  256. } );
  257. it( 'should get empty paragraph (with trim=none)', () => {
  258. schema.register( 'paragraph', { inheritAllFrom: '$block' } );
  259. setData( model, '<paragraph></paragraph>' );
  260. downcastHelpers.elementToElement( { model: 'paragraph', view: 'p' } );
  261. expect( data.get( { trim: 'none' } ) ).to.equal( '<p>&nbsp;</p>' );
  262. } );
  263. it( 'should get two paragraphs', () => {
  264. schema.register( 'paragraph', { inheritAllFrom: '$block' } );
  265. setData( model, '<paragraph>foo</paragraph><paragraph>bar</paragraph>' );
  266. downcastHelpers.elementToElement( { model: 'paragraph', view: 'p' } );
  267. expect( data.get() ).to.equal( '<p>foo</p><p>bar</p>' );
  268. expect( data.get( { trim: 'empty' } ) ).to.equal( '<p>foo</p><p>bar</p>' );
  269. } );
  270. it( 'should get text directly in root', () => {
  271. schema.extend( '$text', { allowIn: '$root' } );
  272. setData( model, 'foo' );
  273. expect( data.get() ).to.equal( 'foo' );
  274. expect( data.get( { trim: 'empty' } ) ).to.equal( 'foo' );
  275. } );
  276. it( 'should get paragraphs without bold', () => {
  277. schema.register( 'paragraph', { inheritAllFrom: '$block' } );
  278. setData( model, '<paragraph>foo<$text bold="true">bar</$text></paragraph>' );
  279. downcastHelpers.elementToElement( { model: 'paragraph', view: 'p' } );
  280. expect( data.get() ).to.equal( '<p>foobar</p>' );
  281. expect( data.get( { trim: 'empty' } ) ).to.equal( '<p>foobar</p>' );
  282. } );
  283. it( 'should get paragraphs with bold', () => {
  284. schema.register( 'paragraph', { inheritAllFrom: '$block' } );
  285. setData( model, '<paragraph>foo<$text bold="true">bar</$text></paragraph>' );
  286. downcastHelpers.elementToElement( { model: 'paragraph', view: 'p' } );
  287. downcastHelpers.attributeToElement( { model: 'bold', view: 'strong' } );
  288. expect( data.get() ).to.equal( '<p>foo<strong>bar</strong></p>' );
  289. expect( data.get( { trim: 'empty' } ) ).to.equal( '<p>foo<strong>bar</strong></p>' );
  290. } );
  291. it( 'should get root name as a parameter', () => {
  292. schema.register( 'paragraph', { inheritAllFrom: '$block' } );
  293. schema.extend( '$text', { allowIn: '$root' } );
  294. setData( model, '<paragraph>foo</paragraph>', { rootName: 'main' } );
  295. setData( model, 'Bar', { rootName: 'title' } );
  296. downcastHelpers.elementToElement( { model: 'paragraph', view: 'p' } );
  297. downcastHelpers.attributeToElement( { model: 'bold', view: 'strong' } );
  298. expect( data.get() ).to.equal( '<p>foo</p>' );
  299. expect( data.get( { rootName: 'main' } ) ).to.equal( '<p>foo</p>' );
  300. expect( data.get( { rootName: 'title' } ) ).to.equal( 'Bar' );
  301. } );
  302. it( 'should throw an error when non-existent root is used', () => {
  303. expectToThrowCKEditorError( () => {
  304. data.get( { rootName: 'nonexistent' } );
  305. }, /datacontroller-get-non-existent-root:/ );
  306. } );
  307. } );
  308. describe( 'stringify()', () => {
  309. beforeEach( () => {
  310. schema.register( 'paragraph', { inheritAllFrom: '$block' } );
  311. schema.register( 'div' );
  312. schema.extend( '$block', { allowIn: 'div' } );
  313. schema.extend( 'div', { allowIn: '$root' } );
  314. downcastHelpers.elementToElement( { model: 'paragraph', view: 'p' } );
  315. } );
  316. it( 'should stringify a content of an element', () => {
  317. const modelElement = parseModel( '<div><paragraph>foo</paragraph></div>', schema );
  318. expect( data.stringify( modelElement ) ).to.equal( '<p>foo</p>' );
  319. } );
  320. it( 'should stringify a content of a document fragment', () => {
  321. const modelDocumentFragment = parseModel( '<paragraph>foo</paragraph><paragraph>bar</paragraph>', schema );
  322. expect( data.stringify( modelDocumentFragment ) ).to.equal( '<p>foo</p><p>bar</p>' );
  323. } );
  324. } );
  325. describe( 'toView()', () => {
  326. beforeEach( () => {
  327. schema.register( 'paragraph', { inheritAllFrom: '$block' } );
  328. schema.register( 'div' );
  329. schema.extend( '$block', { allowIn: 'div' } );
  330. schema.extend( 'div', { allowIn: '$root' } );
  331. downcastHelpers.elementToElement( { model: 'paragraph', view: 'p' } );
  332. } );
  333. it( 'should convert a content of an element', () => {
  334. const modelElement = parseModel( '<div><paragraph>foo</paragraph></div>', schema );
  335. const viewDocumentFragment = data.toView( modelElement );
  336. expect( viewDocumentFragment ).to.be.instanceOf( ViewDocumentFragment );
  337. const viewElement = viewDocumentFragment.getChild( 0 );
  338. expect( viewElement.name ).to.equal( 'p' );
  339. expect( viewElement.childCount ).to.equal( 1 );
  340. expect( viewElement.getChild( 0 ).data ).to.equal( 'foo' );
  341. } );
  342. it( 'should correctly convert document markers #1', () => {
  343. const modelElement = parseModel( '<div><paragraph>foobar</paragraph></div>', schema );
  344. const modelRoot = model.document.getRoot();
  345. downcastHelpers.markerToHighlight( { model: 'marker:a', view: { classes: 'a' } } );
  346. model.change( writer => {
  347. writer.insert( modelElement, modelRoot, 0 );
  348. const range = writer.createRange( writer.createPositionAt( modelRoot, 0 ), writer.createPositionAt( modelRoot, 1 ) );
  349. writer.addMarker( 'marker:a', { range, usingOperation: true } );
  350. } );
  351. const viewDocumentFragment = data.toView( modelElement );
  352. const viewElement = viewDocumentFragment.getChild( 0 );
  353. expect( stringifyView( viewElement ) ).to.equal( '<p><span class="a">foobar</span></p>' );
  354. } );
  355. it( 'should correctly convert document markers #2', () => {
  356. const modelElement = parseModel( '<div><paragraph>foo</paragraph><paragraph>bar</paragraph></div>', schema );
  357. const modelRoot = model.document.getRoot();
  358. downcastHelpers.markerToHighlight( { model: 'marker:a', view: { classes: 'a' } } );
  359. downcastHelpers.markerToHighlight( { model: 'marker:b', view: { classes: 'b' } } );
  360. const modelP1 = modelElement.getChild( 0 );
  361. const modelP2 = modelElement.getChild( 1 );
  362. model.change( writer => {
  363. writer.insert( modelElement, modelRoot, 0 );
  364. const rangeA = writer.createRange( writer.createPositionAt( modelP1, 1 ), writer.createPositionAt( modelP1, 3 ) );
  365. const rangeB = writer.createRange( writer.createPositionAt( modelP2, 0 ), writer.createPositionAt( modelP2, 2 ) );
  366. writer.addMarker( 'marker:a', { range: rangeA, usingOperation: true } );
  367. writer.addMarker( 'marker:b', { range: rangeB, usingOperation: true } );
  368. } );
  369. const viewDocumentFragment = data.toView( modelP1 );
  370. expect( stringifyView( viewDocumentFragment ) ).to.equal( 'f<span class="a">oo</span>' );
  371. } );
  372. it( 'should convert a document fragment', () => {
  373. const modelDocumentFragment = parseModel( '<paragraph>foo</paragraph><paragraph>bar</paragraph>', schema );
  374. const viewDocumentFragment = data.toView( modelDocumentFragment );
  375. expect( viewDocumentFragment ).to.be.instanceOf( ViewDocumentFragment );
  376. expect( viewDocumentFragment ).to.have.property( 'childCount', 2 );
  377. const viewElement = viewDocumentFragment.getChild( 0 );
  378. expect( viewElement.name ).to.equal( 'p' );
  379. expect( viewElement.childCount ).to.equal( 1 );
  380. expect( viewElement.getChild( 0 ).data ).to.equal( 'foo' );
  381. } );
  382. it( 'should keep view-model mapping', () => {
  383. const modelDocumentFragment = parseModel( '<paragraph>foo</paragraph><paragraph>bar</paragraph>', schema );
  384. const viewDocumentFragment = data.toView( modelDocumentFragment );
  385. const firstModelElement = modelDocumentFragment.getChild( 0 );
  386. const firstViewElement = viewDocumentFragment.getChild( 0 );
  387. const modelRange = ModelRange._createOn( firstModelElement );
  388. const viewRange = ViewRange._createOn( firstViewElement );
  389. const mappedModelRange = data.mapper.toModelRange( viewRange );
  390. const mappedViewRange = data.mapper.toViewRange( modelRange );
  391. expect( mappedModelRange ).to.be.instanceOf( ModelRange );
  392. expect( mappedViewRange ).to.be.instanceOf( ViewRange );
  393. expect( mappedModelRange.end.nodeBefore ).to.equal( firstModelElement );
  394. expect( mappedModelRange.end.nodeAfter ).to.equal( modelDocumentFragment.getChild( 1 ) );
  395. expect( mappedViewRange.end.nodeBefore ).to.equal( firstViewElement );
  396. expect( mappedViewRange.end.nodeAfter ).to.equal( viewDocumentFragment.getChild( 1 ) );
  397. } );
  398. } );
  399. describe( 'destroy()', () => {
  400. it( 'should be there for you', () => {
  401. // Should not throw.
  402. data.destroy();
  403. expect( data ).to.respondTo( 'destroy' );
  404. } );
  405. } );
  406. } );