model.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import { stringify, parse, getData, setData } from '../../src/dev-utils/model';
  6. import Model from '../../src/model/model';
  7. import DocumentFragment from '../../src/model/documentfragment';
  8. import Element from '../../src/model/element';
  9. import Text from '../../src/model/text';
  10. import Range from '../../src/model/range';
  11. import Position from '../../src/model/position';
  12. import count from '@ckeditor/ckeditor5-utils/src/count';
  13. describe( 'model test utils', () => {
  14. let model, document, root, selection, sandbox;
  15. beforeEach( () => {
  16. model = new Model();
  17. document = model.document;
  18. root = document.createRoot();
  19. selection = document.selection;
  20. sandbox = sinon.sandbox.create();
  21. selection.removeAllRanges();
  22. model.schema.register( 'a', {
  23. allowWhere: '$text',
  24. allowIn: '$root',
  25. allowAttributes: [ 'bar', 'car', 'foo' ]
  26. } );
  27. model.schema.register( 'b', {
  28. allowWhere: '$text',
  29. allowIn: '$root',
  30. allowAttributes: [ 'barFoo', 'fooBar', 'x' ]
  31. } );
  32. model.schema.register( 'c', {
  33. allowWhere: '$text',
  34. allowIn: [ '$root', 'b' ]
  35. } );
  36. model.schema.register( 'paragraph', { inheritAllFrom: '$block' } );
  37. model.schema.extend( '$text', {
  38. allowIn: [ '$root', 'a', 'b' ]
  39. } );
  40. } );
  41. afterEach( () => {
  42. sandbox.restore();
  43. } );
  44. describe( 'getData', () => {
  45. it( 'should use stringify method', () => {
  46. const stringifySpy = sandbox.spy( getData, '_stringify' );
  47. root.appendChildren( new Element( 'b', null, new Text( 'btext' ) ) );
  48. expect( getData( model, { withoutSelection: true } ) ).to.equal( '<b>btext</b>' );
  49. sinon.assert.calledOnce( stringifySpy );
  50. sinon.assert.calledWithExactly( stringifySpy, root );
  51. } );
  52. it( 'should use stringify method with selection', () => {
  53. const stringifySpy = sandbox.spy( getData, '_stringify' );
  54. root.appendChildren( new Element( 'b', null, new Text( 'btext' ) ) );
  55. document.selection.addRange( Range.createFromParentsAndOffsets( root, 0, root, 1 ) );
  56. expect( getData( model ) ).to.equal( '[<b>btext</b>]' );
  57. sinon.assert.calledOnce( stringifySpy );
  58. sinon.assert.calledWithExactly( stringifySpy, root, document.selection );
  59. } );
  60. it( 'should throw an error when passing invalid document', () => {
  61. expect( () => {
  62. getData( { invalid: 'document' } );
  63. } ).to.throw( TypeError, 'Model needs to be an instance of module:engine/model/model~Model.' );
  64. } );
  65. } );
  66. describe( 'setData', () => {
  67. it( 'should use parse method', () => {
  68. const parseSpy = sandbox.spy( setData, '_parse' );
  69. const options = {};
  70. const data = '<b>btext</b>text';
  71. setData( model, data, options );
  72. expect( getData( model, { withoutSelection: true } ) ).to.equal( data );
  73. sinon.assert.calledOnce( parseSpy );
  74. const args = parseSpy.firstCall.args;
  75. expect( args[ 0 ] ).to.equal( data );
  76. } );
  77. it( 'should use parse method with selection', () => {
  78. const parseSpy = sandbox.spy( setData, '_parse' );
  79. const options = {};
  80. const data = '[<b>btext</b>]';
  81. setData( model, data, options );
  82. expect( getData( model ) ).to.equal( data );
  83. sinon.assert.calledOnce( parseSpy );
  84. const args = parseSpy.firstCall.args;
  85. expect( args[ 0 ] ).to.equal( data );
  86. } );
  87. it( 'should insert text', () => {
  88. test( 'this is test text', '[]this is test text' );
  89. } );
  90. it( 'should insert text with selection around', () => {
  91. test( '[this is test text]' );
  92. } );
  93. it( 'should insert text with selection inside #1', () => {
  94. test( 'this [is test] text' );
  95. } );
  96. it( 'should insert text with selection inside #2', () => {
  97. test( '[this is test] text' );
  98. } );
  99. it( 'should insert text with selection inside #3', () => {
  100. test( 'this is [test text]' );
  101. } );
  102. it( 'should insert unicode text with selection', () => {
  103. test( 'நி[லைக்]கு' );
  104. } );
  105. it( 'should insert element', () => {
  106. test( '<b>foo bar</b>', '[]<b>foo bar</b>' );
  107. } );
  108. it( 'should insert element with selection inside #1', () => {
  109. test( '<b>[foo ]bar</b>' );
  110. } );
  111. it( 'should insert element with selection inside #2', () => {
  112. test( '[<b>foo ]bar</b>' );
  113. } );
  114. it( 'should insert element with selection inside #3', () => {
  115. test( '<b>[foo bar</b>]' );
  116. } );
  117. it( 'should insert backward selection', () => {
  118. setData( model, '<b>[foo bar</b>]', { lastRangeBackward: true } );
  119. expect( getData( model ) ).to.equal( '<b>[foo bar</b>]' );
  120. expect( document.selection.isBackward ).to.true;
  121. } );
  122. it( 'should throw an error when passing invalid document', () => {
  123. expect( () => {
  124. setData( { invalid: 'document' } );
  125. } ).to.throw( TypeError, 'Model needs to be an instance of module:engine/model/model~Model.' );
  126. } );
  127. it( 'should set attributes to the selection', () => {
  128. setData( model, '<b>[foo bar]</b>', { selectionAttributes: { foo: 'bar' } } );
  129. expect( document.selection.getAttribute( 'foo' ) ).to.equal( 'bar' );
  130. } );
  131. // #815.
  132. it( 'should work in a special root', () => {
  133. const model = new Model();
  134. model.schema.register( 'textOnly' );
  135. model.schema.extend( '$text', { allowIn: 'textOnly' } );
  136. model.document.createRoot( 'textOnly', 'textOnly' );
  137. setData( model, 'a[b]c', { rootName: 'textOnly' } );
  138. expect( getData( model, { rootName: 'textOnly' } ) ).to.equal( 'a[b]c' );
  139. } );
  140. function test( data, expected ) {
  141. expected = expected || data;
  142. setData( model, data );
  143. expect( getData( model ) ).to.equal( expected );
  144. }
  145. } );
  146. describe( 'stringify', () => {
  147. it( 'should stringify text', () => {
  148. const text = new Text( 'text', { underline: true, bold: true } );
  149. expect( stringify( text ) ).to.equal( '<$text bold="true" underline="true">text</$text>' );
  150. } );
  151. it( 'should stringify element', () => {
  152. const element = new Element( 'a', null, [
  153. new Element( 'b', null, new Text( 'btext' ) ),
  154. new Text( 'atext' )
  155. ] );
  156. expect( stringify( element ) ).to.equal( '<a><b>btext</b>atext</a>' );
  157. } );
  158. it( 'should stringify document fragment', () => {
  159. const fragment = new DocumentFragment( [
  160. new Element( 'b', null, new Text( 'btext' ) ),
  161. new Text( 'atext' )
  162. ] );
  163. expect( stringify( fragment ) ).to.equal( '<b>btext</b>atext' );
  164. } );
  165. it( 'writes elements and texts', () => {
  166. root.appendChildren( [
  167. new Element( 'a', null, new Text( 'atext' ) ),
  168. new Element( 'b', null, [
  169. new Element( 'c1' ),
  170. new Text( 'ctext' ),
  171. new Element( 'c2' )
  172. ] ),
  173. new Element( 'd' )
  174. ] );
  175. expect( stringify( root ) ).to.equal(
  176. '<a>atext</a><b><c1></c1>ctext<c2></c2></b><d></d>'
  177. );
  178. } );
  179. it( 'writes element attributes', () => {
  180. root.appendChildren(
  181. new Element( 'a', { foo: true, bar: 1, car: false }, [
  182. new Element( 'b', { fooBar: 'x y', barFoo: { x: 1, y: 2 } } )
  183. ] )
  184. );
  185. // Note: attributes are written in a very simplistic way, because they are not to be parsed. They are just
  186. // to be compared in the tests with some patterns.
  187. expect( stringify( root ) ).to.equal(
  188. '<a bar="1" car="false" foo="true"><b barFoo="{"x":1,"y":2}" fooBar="x y"></b></a>'
  189. );
  190. } );
  191. it( 'writes text attributes', () => {
  192. root.appendChildren( [
  193. new Text( 'foo', { bold: true } ),
  194. new Text( 'bar' ),
  195. new Text( 'bom', { bold: true, italic: true } ),
  196. new Element( 'a', null, [
  197. new Text( 'pom', { underline: true, bold: true } )
  198. ] )
  199. ] );
  200. expect( stringify( root ) ).to.equal(
  201. '<$text bold="true">foo</$text>bar<$text bold="true" italic="true">bom</$text>' +
  202. '<a><$text bold="true" underline="true">pom</$text></a>'
  203. );
  204. } );
  205. it( 'writes unicode text', () => {
  206. root.appendChildren( new Text( 'நிலைக்கு' ) );
  207. expect( stringify( root ) ).to.equal( 'நிலைக்கு' );
  208. } );
  209. describe( 'selection', () => {
  210. let elA, elB;
  211. beforeEach( () => {
  212. elA = new Element( 'a' );
  213. elB = new Element( 'b' );
  214. root.appendChildren( [
  215. elA,
  216. new Text( 'foo' ),
  217. new Text( 'bar', { bold: true } ),
  218. elB
  219. ] );
  220. } );
  221. it( 'writes selection in an empty root', () => {
  222. const root = document.createRoot( '$root', 'empty' );
  223. selection.setCollapsedAt( root );
  224. expect( stringify( root, selection ) ).to.equal(
  225. '[]'
  226. );
  227. } );
  228. it( 'writes selection collapsed in an element', () => {
  229. selection.setCollapsedAt( root );
  230. expect( stringify( root, selection ) ).to.equal(
  231. '[]<a></a>foo<$text bold="true">bar</$text><b></b>'
  232. );
  233. } );
  234. it( 'writes selection collapsed in a text', () => {
  235. selection.setCollapsedAt( root, 3 );
  236. expect( stringify( root, selection ) ).to.equal(
  237. '<a></a>fo[]o<$text bold="true">bar</$text><b></b>'
  238. );
  239. } );
  240. it( 'writes selection collapsed at the text left boundary', () => {
  241. selection.setCollapsedAt( elA, 'after' );
  242. expect( stringify( root, selection ) ).to.equal(
  243. '<a></a>[]foo<$text bold="true">bar</$text><b></b>'
  244. );
  245. } );
  246. it( 'writes selection collapsed at the text right boundary', () => {
  247. selection.setCollapsedAt( elB, 'before' );
  248. expect( stringify( root, selection ) ).to.equal(
  249. '<a></a>foo<$text bold="true">bar[]</$text><b></b>'
  250. );
  251. } );
  252. it( 'writes selection collapsed at the end of the root', () => {
  253. selection.setCollapsedAt( root, 'end' );
  254. // Needed due to https://github.com/ckeditor/ckeditor5-engine/issues/320.
  255. selection.clearAttributes();
  256. expect( stringify( root, selection ) ).to.equal(
  257. '<a></a>foo<$text bold="true">bar</$text><b></b>[]'
  258. );
  259. } );
  260. it( 'writes selection collapsed selection in a text with attributes', () => {
  261. selection.setCollapsedAt( root, 5 );
  262. expect( stringify( root, selection ) ).to.equal(
  263. '<a></a>foo<$text bold="true">b[]ar</$text><b></b>'
  264. );
  265. } );
  266. it( 'writes flat selection containing couple of nodes', () => {
  267. selection.addRange(
  268. Range.createFromParentsAndOffsets( root, 0, root, 4 )
  269. );
  270. expect( stringify( root, selection ) ).to.equal(
  271. '[<a></a>foo]<$text bold="true">bar</$text><b></b>'
  272. );
  273. } );
  274. it( 'writes flat selection within text', () => {
  275. selection.addRange(
  276. Range.createFromParentsAndOffsets( root, 2, root, 3 )
  277. );
  278. expect( stringify( root, selection ) ).to.equal(
  279. '<a></a>f[o]o<$text bold="true">bar</$text><b></b>'
  280. );
  281. } );
  282. it( 'writes multi-level selection', () => {
  283. selection.addRange(
  284. Range.createFromParentsAndOffsets( elA, 0, elB, 0 )
  285. );
  286. expect( stringify( root, selection ) ).to.equal(
  287. '<a>[</a>foo<$text bold="true">bar</$text><b>]</b>'
  288. );
  289. } );
  290. it( 'writes selection when is backward', () => {
  291. selection.addRange(
  292. Range.createFromParentsAndOffsets( elA, 0, elB, 0 ),
  293. true
  294. );
  295. expect( stringify( root, selection ) ).to.equal(
  296. '<a>[</a>foo<$text bold="true">bar</$text><b>]</b>'
  297. );
  298. } );
  299. it( 'writes selection in unicode text', () => {
  300. const root = document.createRoot( '$root', 'empty' );
  301. root.appendChildren( new Text( 'நிலைக்கு' ) );
  302. selection.addRange( Range.createFromParentsAndOffsets( root, 2, root, 6 ) );
  303. expect( stringify( root, selection ) ).to.equal( 'நி[லைக்]கு' );
  304. } );
  305. it( 'uses range and coverts it to selection', () => {
  306. const range = Range.createFromParentsAndOffsets( elA, 0, elB, 0 );
  307. expect( stringify( root, range ) ).to.equal(
  308. '<a>[</a>foo<$text bold="true">bar</$text><b>]</b>'
  309. );
  310. } );
  311. it( 'uses position and converts it to collapsed selection', () => {
  312. const position = new Position( root, [ 0 ] );
  313. expect( stringify( root, position ) ).to.equal(
  314. '[]<a></a>foo<$text bold="true">bar</$text><b></b>'
  315. );
  316. } );
  317. } );
  318. } );
  319. describe( 'parse', () => {
  320. test( 'creates empty DocumentFragment from empty string', {
  321. data: '',
  322. check( fragment ) {
  323. expect( fragment ).to.be.instanceOf( DocumentFragment );
  324. }
  325. } );
  326. test( 'creates empty DocumentFragment with selection', {
  327. data: '[]',
  328. check( fragment, selection ) {
  329. expect( fragment ).to.be.instanceOf( DocumentFragment );
  330. expect( fragment.childCount ).to.equal( 0 );
  331. expect( selection.rangeCount ).to.equal( 1 );
  332. expect( selection.getFirstRange().isEqual( Range.createFromParentsAndOffsets( fragment, 0, fragment, 0 ) ) ).to.be.true;
  333. }
  334. } );
  335. test( 'returns Element if range is around single element', {
  336. data: '[<a></a>]',
  337. check( el, selection ) {
  338. const fragment = el.parent;
  339. expect( el ).to.be.instanceOf( Element );
  340. expect( fragment ).to.be.instanceOf( DocumentFragment );
  341. expect( selection.rangeCount ).to.equal( 1 );
  342. expect( selection.getFirstRange().isEqual( Range.createFromParentsAndOffsets( fragment, 0, fragment, 1 ) ) ).to.be.true;
  343. }
  344. } );
  345. test( 'returns DocumentFragment when multiple elements on root', {
  346. data: '<a></a><b></b>',
  347. check( fragment ) {
  348. expect( fragment ).to.be.instanceOf( DocumentFragment );
  349. expect( fragment.childCount ).to.equal( 2 );
  350. }
  351. } );
  352. test( 'creates elements', {
  353. data: '<a></a><b><c></c></b>'
  354. } );
  355. test( 'creates text nodes', {
  356. data: 'foo<a>bar</a>bom'
  357. } );
  358. test( 'creates text nodes with unicode text', {
  359. data: 'நிலைக்கு'
  360. } );
  361. test( 'sets elements attributes', {
  362. data: '<a bar="true" car="x y" foo="1"></a><b x="y"></b>',
  363. output: '<a bar="true" car="x y" foo="1"></a><b x="y"></b>',
  364. check( root ) {
  365. expect( root.getChild( 0 ).getAttribute( 'bar' ) ).to.equal( true );
  366. expect( root.getChild( 0 ).getAttribute( 'car' ) ).to.equal( 'x y' );
  367. expect( root.getChild( 0 ).getAttribute( 'foo' ) ).to.equal( 1 );
  368. expect( root.getChild( 1 ).getAttribute( 'x' ) ).to.equal( 'y' );
  369. }
  370. } );
  371. test( 'sets text attributes', {
  372. data: '<$text bar="true" car="x y" foo="1">foo</$text><$text x="y">bar</$text>bom',
  373. check( root ) {
  374. expect( root.childCount ).to.equal( 3 );
  375. expect( root.maxOffset ).to.equal( 9 );
  376. expect( root.getChild( 0 ).getAttribute( 'bar' ) ).to.equal( true );
  377. expect( root.getChild( 0 ).getAttribute( 'car' ) ).to.equal( 'x y' );
  378. expect( root.getChild( 0 ).getAttribute( 'foo' ) ).to.equal( 1 );
  379. expect( root.getChild( 1 ).getAttribute( 'x' ) ).to.equal( 'y' );
  380. expect( count( root.getChild( 2 ).getAttributes() ) ).to.equal( 0 );
  381. }
  382. } );
  383. test( 'creates element with complex attributes', {
  384. data: '<a foo=\'{"x":1,"y":2}\'></a>',
  385. output: '<a foo="{"x":1,"y":2}"></a>',
  386. check( a ) {
  387. expect( count( a.getAttributes() ) ).to.equal( 1 );
  388. expect( a.getAttribute( 'foo' ) ).to.have.property( 'x', 1 );
  389. expect( a.getAttribute( 'foo' ) ).to.have.property( 'y', 2 );
  390. }
  391. } );
  392. test( 'returns single parsed element', {
  393. data: '<paragraph></paragraph>',
  394. check( p ) {
  395. expect( p instanceof Element ).to.be.true;
  396. }
  397. } );
  398. test( 'returns DocumentFragment for multiple parsed elements', {
  399. data: '<paragraph></paragraph><paragraph></paragraph>',
  400. check( fragment ) {
  401. expect( fragment instanceof DocumentFragment ).to.be.true;
  402. }
  403. } );
  404. it( 'throws when invalid XML', () => {
  405. expect( () => {
  406. parse( '<a><b></a></b>', model.schema );
  407. } ).to.throw( Error, /Parse error/ );
  408. } );
  409. it( 'throws when try to set element not registered in schema', () => {
  410. expect( () => {
  411. parse( '<xyz></xyz>', model.schema );
  412. } ).to.throw( Error, 'Element \'xyz\' was not allowed in context ["$root"].' );
  413. } );
  414. it( 'throws when try to set text directly to $root without registering it', () => {
  415. const model = new Model();
  416. expect( () => {
  417. parse( 'text', model.schema );
  418. } ).to.throw( Error, 'Text was not allowed in context ["$root"].' );
  419. } );
  420. it( 'converts data in the specified context', () => {
  421. const model = new Model();
  422. model.schema.register( 'foo' );
  423. model.schema.extend( '$text', { allowIn: 'foo' } );
  424. expect( () => {
  425. parse( 'text', model.schema, { context: [ 'foo' ] } );
  426. } ).to.not.throw();
  427. } );
  428. describe( 'selection', () => {
  429. test( 'sets collapsed selection in an element', {
  430. data: '<a>[]</a>',
  431. check( root, selection ) {
  432. expect( selection.getFirstPosition().parent ).to.have.property( 'name', 'a' );
  433. }
  434. } );
  435. test( 'sets collapsed selection between elements', {
  436. data: '<a></a>[]<b></b>'
  437. } );
  438. test( 'sets collapsed selection before a text', {
  439. data: '<a></a>[]foo'
  440. } );
  441. test( 'sets collapsed selection after a text', {
  442. data: 'foo[]'
  443. } );
  444. test( 'sets collapsed selection within a text', {
  445. data: 'foo[]bar',
  446. check( text, selection ) {
  447. expect( text.offsetSize ).to.equal( 6 );
  448. expect( text.getPath() ).to.deep.equal( [ 0 ] );
  449. expect( selection.getFirstRange().start.path ).to.deep.equal( [ 3 ] );
  450. expect( selection.getFirstRange().end.path ).to.deep.equal( [ 3 ] );
  451. }
  452. } );
  453. it( 'sets selection attributes', () => {
  454. const result = parse( 'foo[]bar', model.schema, { selectionAttributes: {
  455. bold: true,
  456. italic: true
  457. } } );
  458. expect( stringify( result.model, result.selection ) ).to.equal( 'foo<$text bold="true" italic="true">[]</$text>bar' );
  459. } );
  460. test( 'sets collapsed selection between text and text with attributes', {
  461. data: 'foo[]<$text bold="true">bar</$text>',
  462. check( root, selection ) {
  463. expect( root.maxOffset ).to.equal( 6 );
  464. expect( selection.getAttribute( 'bold' ) ).to.be.undefined;
  465. }
  466. } );
  467. test( 'sets selection containing an element', {
  468. data: 'x[<a></a>]'
  469. } );
  470. it( 'sets selection with attribute containing an element', () => {
  471. const result = parse( 'x[<a></a>]', model.schema, { selectionAttributes: {
  472. bold: true
  473. } } );
  474. expect( stringify( result.model, result.selection ) ).to.equal( 'x[<a></a>]' );
  475. expect( result.selection.getAttribute( 'bold' ) ).to.be.true;
  476. } );
  477. it( 'sets a backward selection containing an element', () => {
  478. const result = parse( 'x[<a></a>]', model.schema, {
  479. lastRangeBackward: true
  480. } );
  481. expect( stringify( result.model, result.selection ) ).to.equal( 'x[<a></a>]' );
  482. expect( result.selection.isBackward ).to.true;
  483. } );
  484. test( 'sets selection within a text', {
  485. data: 'x[y]z'
  486. } );
  487. it( 'sets selection within a text with different attributes', () => {
  488. const result = parse( '<$text bold="true">fo[o</$text>ba]r', model.schema, {
  489. selectionAttributes: { bold: true }
  490. } );
  491. expect( stringify( result.model, result.selection ) ).to.equal( '<$text bold="true">fo[o</$text>ba]r' );
  492. expect( result.selection.getAttribute( 'bold' ) ).to.true;
  493. } );
  494. it( 'throws when missing selection start', () => {
  495. expect( () => {
  496. parse( 'foo]', model.schema );
  497. } ).to.throw( Error, /^Parse error/ );
  498. } );
  499. it( 'throws when missing selection end', () => {
  500. expect( () => {
  501. parse( '[foo', model.schema );
  502. } ).to.throw( Error, /^Parse error/ );
  503. } );
  504. } );
  505. function test( title, options ) {
  506. it( title, () => {
  507. const output = options.output || options.data;
  508. const data = parse( options.data, model.schema );
  509. let converted, selection;
  510. if ( data.selection && data.model ) {
  511. converted = data.model;
  512. selection = data.selection;
  513. } else {
  514. converted = data;
  515. }
  516. expect( stringify( converted, selection ) ).to.equal( output );
  517. if ( options.check ) {
  518. options.check( converted, selection );
  519. }
  520. } );
  521. }
  522. } );
  523. } );