treewalker.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  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 Model from '../../src/model/model';
  6. import DocumentFragment from '../../src/model/documentfragment';
  7. import Element from '../../src/model/element';
  8. import Text from '../../src/model/text';
  9. import TreeWalker from '../../src/model/treewalker';
  10. import Position from '../../src/model/position';
  11. import Range from '../../src/model/range';
  12. import { expectToThrowCKEditorError } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
  13. describe( 'TreeWalker', () => {
  14. let model, doc, root, img1, paragraph, ba, r, img2, x,
  15. rootBeginning, rootEnding;
  16. beforeEach( () => {
  17. model = new Model();
  18. doc = model.document;
  19. root = doc.createRoot();
  20. // root
  21. // |- img1
  22. // |- p
  23. // |- B -bold
  24. // |- A -bold
  25. // |- R
  26. // |
  27. // |- img2
  28. // |
  29. // |- X
  30. ba = new Text( 'ba', { bold: true } );
  31. r = new Text( 'r' );
  32. img2 = new Element( 'img2' );
  33. x = new Text( 'x' );
  34. paragraph = new Element( 'p', [], [ ba, r, img2, x ] );
  35. img1 = new Element( 'img1' );
  36. root._insertChild( 0, [ img1, paragraph ] );
  37. rootBeginning = new Position( root, [ 0 ] );
  38. rootEnding = new Position( root, [ 2 ] );
  39. } );
  40. describe( 'constructor()', () => {
  41. it( 'should throw if neither boundaries nor starting position is set', () => {
  42. expectToThrowCKEditorError( () => {
  43. new TreeWalker(); // eslint-disable-line no-new
  44. }, /^model-tree-walker-no-start-position/, null );
  45. expectToThrowCKEditorError( () => {
  46. new TreeWalker( {} ); // eslint-disable-line no-new
  47. }, /^model-tree-walker-no-start-position/, null );
  48. expectToThrowCKEditorError( () => {
  49. new TreeWalker( { singleCharacters: true } ); // eslint-disable-line no-new
  50. }, /^model-tree-walker-no-start-position/, null );
  51. } );
  52. it( 'should throw if walking direction is unknown', () => {
  53. expectToThrowCKEditorError( () => {
  54. new TreeWalker( { startPosition: rootBeginning, direction: 'unknown' } ); // eslint-disable-line no-new
  55. }, /^model-tree-walker-unknown-direction/, model );
  56. } );
  57. } );
  58. describe( 'iterate from start position `startPosition`', () => {
  59. let expected;
  60. beforeEach( () => {
  61. expected = [
  62. { type: 'elementStart', item: img1 },
  63. { type: 'elementEnd', item: img1 },
  64. { type: 'elementStart', item: paragraph },
  65. { type: 'text', data: 'ba', attrs: [ [ 'bold', true ] ] },
  66. { type: 'text', data: 'r', attrs: [] },
  67. { type: 'elementStart', item: img2 },
  68. { type: 'elementEnd', item: img2 },
  69. { type: 'text', data: 'x', attrs: [] },
  70. { type: 'elementEnd', item: paragraph }
  71. ];
  72. } );
  73. it( 'should provide iterator interface with default forward direction', () => {
  74. const iterator = new TreeWalker( { startPosition: rootBeginning } );
  75. let i = 0;
  76. for ( const value of iterator ) {
  77. expectValue( value, expected[ i ] );
  78. i++;
  79. }
  80. expect( i ).to.equal( expected.length );
  81. } );
  82. it( 'should provide iterator interface with forward direction', () => {
  83. const iterator = new TreeWalker( { startPosition: rootBeginning, direction: 'forward' } );
  84. let i = 0;
  85. for ( const value of iterator ) {
  86. expectValue( value, expected[ i ] );
  87. i++;
  88. }
  89. expect( i ).to.equal( expected.length );
  90. } );
  91. it( 'should provide iterator interface which backward direction', () => {
  92. const iterator = new TreeWalker( { startPosition: rootEnding, direction: 'backward' } );
  93. let i = expected.length;
  94. for ( const value of iterator ) {
  95. expectValue( value, expected[ --i ], { direction: 'backward' } );
  96. }
  97. expect( i ).to.equal( 0 );
  98. } );
  99. it( 'should start iterating at the startPosition witch is not a root bound', () => {
  100. const iterator = new TreeWalker( { startPosition: new Position( root, [ 1 ] ) } );
  101. let i = 2;
  102. for ( const value of iterator ) {
  103. expectValue( value, expected[ i ] );
  104. i++;
  105. }
  106. expect( i ).to.equal( expected.length );
  107. } );
  108. it( 'should start iterating at the startPosition witch is not a root bound, going backward', () => {
  109. const expected = [
  110. { type: 'elementStart', item: img1 },
  111. { type: 'elementEnd', item: img1 }
  112. ];
  113. const iterator = new TreeWalker( { startPosition: new Position( root, [ 1 ] ), direction: 'backward' } );
  114. let i = expected.length;
  115. for ( const value of iterator ) {
  116. expectValue( value, expected[ --i ], { direction: 'backward' } );
  117. }
  118. expect( i ).to.equal( 0 );
  119. } );
  120. } );
  121. describe( 'iterate trough the range `boundary`', () => {
  122. describe( 'range starts between elements', () => {
  123. let expected, range;
  124. beforeEach( () => {
  125. expected = [
  126. { type: 'elementStart', item: paragraph },
  127. { type: 'text', data: 'ba', attrs: [ [ 'bold', true ] ] },
  128. { type: 'text', data: 'r', attrs: [] },
  129. { type: 'elementStart', item: img2 },
  130. { type: 'elementEnd', item: img2 }
  131. ];
  132. range = new Range( new Position( root, [ 1 ] ), new Position( root, [ 1, 4 ] ) );
  133. } );
  134. it( 'should iterate over the range', () => {
  135. const iterator = new TreeWalker( { boundaries: range } );
  136. let i = 0;
  137. for ( const value of iterator ) {
  138. expectValue( value, expected[ i ] );
  139. i++;
  140. }
  141. expect( i ).to.equal( expected.length );
  142. } );
  143. it( 'should iterate over the range going backward', () => {
  144. const iterator = new TreeWalker( { boundaries: range, direction: 'backward' } );
  145. let i = expected.length;
  146. for ( const value of iterator ) {
  147. expectValue( value, expected[ --i ], { direction: 'backward' } );
  148. }
  149. expect( i ).to.equal( 0 );
  150. } );
  151. } );
  152. describe( 'range starts inside the text', () => {
  153. let expected, range;
  154. beforeEach( () => {
  155. expected = [
  156. { type: 'text', data: 'a', attrs: [ [ 'bold', true ] ] },
  157. { type: 'text', data: 'r', attrs: [] },
  158. { type: 'elementStart', item: img2 },
  159. { type: 'elementEnd', item: img2 }
  160. ];
  161. range = new Range( new Position( root, [ 1, 1 ] ), new Position( root, [ 1, 4 ] ) );
  162. } );
  163. it( 'should return part of the text', () => {
  164. const iterator = new TreeWalker( { boundaries: range } );
  165. let i = 0;
  166. for ( const value of iterator ) {
  167. expectValue( value, expected[ i ] );
  168. i++;
  169. }
  170. expect( i ).to.equal( expected.length );
  171. } );
  172. it( 'should return part of the text going backward', () => {
  173. const iterator = new TreeWalker( {
  174. boundaries: range,
  175. direction: 'backward' }
  176. );
  177. let i = expected.length;
  178. for ( const value of iterator ) {
  179. expectValue( value, expected[ --i ], { direction: 'backward' } );
  180. }
  181. expect( i ).to.equal( 0 );
  182. } );
  183. } );
  184. describe( 'range ends inside the text', () => {
  185. let expected, range;
  186. beforeEach( () => {
  187. expected = [
  188. { type: 'elementStart', item: img1 },
  189. { type: 'elementEnd', item: img1 },
  190. { type: 'elementStart', item: paragraph },
  191. { type: 'text', data: 'b', attrs: [ [ 'bold', true ] ] }
  192. ];
  193. range = new Range( rootBeginning, new Position( root, [ 1, 1 ] ) );
  194. } );
  195. it( 'should return part of the text', () => {
  196. const iterator = new TreeWalker( { boundaries: range } );
  197. let i = 0;
  198. for ( const value of iterator ) {
  199. expectValue( value, expected[ i ] );
  200. i++;
  201. }
  202. expect( i ).to.equal( expected.length );
  203. } );
  204. it( 'should return part of the text going backward', () => {
  205. const iterator = new TreeWalker( {
  206. boundaries: range,
  207. startPosition: range.end,
  208. direction: 'backward'
  209. } );
  210. let i = expected.length;
  211. for ( const value of iterator ) {
  212. expectValue( value, expected[ --i ], { direction: 'backward' } );
  213. }
  214. expect( i ).to.equal( 0 );
  215. } );
  216. } );
  217. describe( 'custom start position', () => {
  218. it( 'should iterating from the start position', () => {
  219. const expected = [
  220. { type: 'text', data: 'r', attrs: [] },
  221. { type: 'elementStart', item: img2 },
  222. { type: 'elementEnd', item: img2 }
  223. ];
  224. const range = new Range( new Position( root, [ 1 ] ), new Position( root, [ 1, 4 ] ) );
  225. const iterator = new TreeWalker( {
  226. boundaries: range,
  227. startPosition: new Position( root, [ 1, 2 ] )
  228. } );
  229. let i = 0;
  230. for ( const value of iterator ) {
  231. expectValue( value, expected[ i ] );
  232. i++;
  233. }
  234. expect( i ).to.equal( expected.length );
  235. } );
  236. it( 'should iterating from the start position going backward', () => {
  237. const expected = [
  238. { type: 'text', data: 'r', attrs: [] },
  239. { type: 'elementStart', item: img2 },
  240. { type: 'elementEnd', item: img2 }
  241. ];
  242. const range = new Range( new Position( root, [ 1, 2 ] ), new Position( root, [ 1, 6 ] ) );
  243. const iterator = new TreeWalker( {
  244. boundaries: range,
  245. startPosition: new Position( root, [ 1, 4 ] ),
  246. direction: 'backward'
  247. } );
  248. let i = expected.length;
  249. for ( const value of iterator ) {
  250. expectValue( value, expected[ --i ], { direction: 'backward' } );
  251. }
  252. expect( i ).to.equal( 0 );
  253. } );
  254. } );
  255. } );
  256. describe( 'iterate by every single characters `singleCharacter`', () => {
  257. describe( 'whole root', () => {
  258. let expected;
  259. beforeEach( () => {
  260. expected = [
  261. { type: 'elementStart', item: img1 },
  262. { type: 'elementEnd', item: img1 },
  263. { type: 'elementStart', item: paragraph },
  264. { type: 'text', data: 'b', attrs: [ [ 'bold', true ] ] },
  265. { type: 'text', data: 'a', attrs: [ [ 'bold', true ] ] },
  266. { type: 'text', data: 'r', attrs: [] },
  267. { type: 'elementStart', item: img2 },
  268. { type: 'elementEnd', item: img2 },
  269. { type: 'text', data: 'x', attrs: [] },
  270. { type: 'elementEnd', item: paragraph }
  271. ];
  272. } );
  273. it( 'should return single characters', () => {
  274. const iterator = new TreeWalker( { startPosition: rootBeginning, singleCharacters: true } );
  275. let i = 0;
  276. for ( const value of iterator ) {
  277. expectValue( value, expected[ i ] );
  278. i++;
  279. }
  280. expect( i ).to.equal( expected.length );
  281. } );
  282. it( 'should return single characters going backward', () => {
  283. const iterator = new TreeWalker( {
  284. startPosition: rootEnding,
  285. singleCharacters: true,
  286. direction: 'backward' }
  287. );
  288. let i = expected.length;
  289. for ( const value of iterator ) {
  290. expectValue( value, expected[ --i ], { direction: 'backward' } );
  291. }
  292. expect( i ).to.equal( 0 );
  293. } );
  294. } );
  295. describe( 'range', () => {
  296. let start, end, range, expected;
  297. beforeEach( () => {
  298. expected = [
  299. { type: 'text', data: 'b', attrs: [ [ 'bold', true ] ] },
  300. { type: 'text', data: 'a', attrs: [ [ 'bold', true ] ] },
  301. { type: 'text', data: 'r', attrs: [] },
  302. { type: 'elementStart', item: img2 }
  303. ];
  304. start = new Position( root, [ 1, 0 ] ); // p, 0
  305. end = new Position( root, [ 1, 3, 0 ] ); // img2, 0
  306. range = new Range( start, end );
  307. } );
  308. it( 'should respect boundaries', () => {
  309. const iterator = new TreeWalker( { boundaries: range, singleCharacters: true } );
  310. let i = 0;
  311. for ( const value of iterator ) {
  312. expectValue( value, expected[ i ] );
  313. i++;
  314. }
  315. expect( i ).to.equal( expected.length );
  316. } );
  317. it( 'should respect boundaries going backward', () => {
  318. const iterator = new TreeWalker( {
  319. boundaries: range,
  320. singleCharacters: true,
  321. startPosition: range.end,
  322. direction: 'backward'
  323. } );
  324. let i = expected.length;
  325. for ( const value of iterator ) {
  326. expectValue( value, expected[ --i ], { direction: 'backward' } );
  327. }
  328. expect( i ).to.equal( 0 );
  329. } );
  330. } );
  331. } );
  332. describe( 'iterate omitting child nodes and elementEnd `shallow`', () => {
  333. let expected;
  334. beforeEach( () => {
  335. expected = [
  336. { type: 'elementStart', item: img1 },
  337. { type: 'elementStart', item: paragraph }
  338. ];
  339. } );
  340. it( 'should not enter elements', () => {
  341. const iterator = new TreeWalker( { startPosition: rootBeginning, shallow: true } );
  342. let i = 0;
  343. for ( const value of iterator ) {
  344. expectValue( value, expected[ i ], { shallow: true } );
  345. i++;
  346. }
  347. expect( i ).to.equal( expected.length );
  348. } );
  349. it( 'should not enter elements going backward', () => {
  350. const iterator = new TreeWalker( { startPosition: rootEnding, shallow: true, direction: 'backward' } );
  351. let i = expected.length;
  352. for ( const value of iterator ) {
  353. expectValue( value, expected[ --i ], { shallow: true, direction: 'backward' } );
  354. }
  355. expect( i ).to.equal( 0 );
  356. } );
  357. } );
  358. describe( 'iterate omitting elementEnd `ignoreElementEnd`', () => {
  359. describe( 'merged text', () => {
  360. let expected;
  361. beforeEach( () => {
  362. expected = [
  363. { type: 'elementStart', item: img1 },
  364. { type: 'elementStart', item: paragraph },
  365. { type: 'text', data: 'ba', attrs: [ [ 'bold', true ] ] },
  366. { type: 'text', data: 'r', attrs: [] },
  367. { type: 'elementStart', item: img2 },
  368. { type: 'text', data: 'x', attrs: [] }
  369. ];
  370. } );
  371. it( 'should iterate ignoring elementEnd', () => {
  372. const iterator = new TreeWalker( { startPosition: rootBeginning, ignoreElementEnd: true } );
  373. let i = 0;
  374. for ( const value of iterator ) {
  375. expectValue( value, expected[ i ] );
  376. i++;
  377. }
  378. expect( i ).to.equal( expected.length );
  379. } );
  380. it( 'should iterate ignoring elementEnd going backward', () => {
  381. const iterator = new TreeWalker( {
  382. startPosition: rootEnding,
  383. ignoreElementEnd: true,
  384. direction: 'backward'
  385. } );
  386. let i = expected.length;
  387. for ( const value of iterator ) {
  388. expectValue( value, expected[ --i ], { direction: 'backward' } );
  389. }
  390. expect( i ).to.equal( 0 );
  391. } );
  392. } );
  393. describe( 'single character', () => {
  394. let expected;
  395. beforeEach( () => {
  396. expected = [
  397. { type: 'elementStart', item: img1 },
  398. { type: 'elementStart', item: paragraph },
  399. { type: 'text', data: 'b', attrs: [ [ 'bold', true ] ] },
  400. { type: 'text', data: 'a', attrs: [ [ 'bold', true ] ] },
  401. { type: 'text', data: 'r', attrs: [] },
  402. { type: 'elementStart', item: img2 },
  403. { type: 'text', data: 'x', attrs: [] }
  404. ];
  405. } );
  406. it( 'should return single characters ignoring elementEnd', () => {
  407. const iterator = new TreeWalker( {
  408. startPosition: rootBeginning,
  409. singleCharacters: true,
  410. ignoreElementEnd: true
  411. } );
  412. let i = 0;
  413. for ( const value of iterator ) {
  414. expectValue( value, expected[ i ] );
  415. i++;
  416. }
  417. expect( i ).to.equal( expected.length );
  418. } );
  419. it( 'should return single characters ignoring elementEnd going backward', () => {
  420. const iterator = new TreeWalker( {
  421. startPosition: rootEnding,
  422. singleCharacters: true,
  423. ignoreElementEnd: true,
  424. direction: 'backward'
  425. } );
  426. let i = expected.length;
  427. for ( const value of iterator ) {
  428. expectValue( value, expected[ --i ], { direction: 'backward' } );
  429. }
  430. expect( i ).to.equal( 0 );
  431. } );
  432. } );
  433. } );
  434. it( 'should iterate over document fragment', () => {
  435. const foo = new Text( 'foo' );
  436. const bar = new Text( 'bar' );
  437. const p = new Element( 'p', null, [ foo, bar ] );
  438. const docFrag = new DocumentFragment( [ p ] );
  439. const iterator = new TreeWalker( {
  440. startPosition: new Position( docFrag, [ 0 ] ),
  441. ignoreElementEnd: true
  442. } );
  443. const expected = [
  444. { type: 'elementStart', item: p },
  445. { type: 'text', data: 'foo', attrs: [] },
  446. { type: 'text', data: 'bar', attrs: [] }
  447. ];
  448. let i = 0;
  449. for ( const value of iterator ) {
  450. expectValue( value, expected[ i++ ], { ignoreElementEnd: true } );
  451. }
  452. } );
  453. describe( 'skip', () => {
  454. describe( 'forward treewalker', () => {
  455. it( 'should jump over all text nodes', () => {
  456. const walker = new TreeWalker( {
  457. startPosition: Position._createAt( paragraph, 0 )
  458. } );
  459. walker.skip( value => value.type == 'text' );
  460. expect( walker.position.parent ).to.equal( paragraph );
  461. expect( walker.position.offset ).to.equal( 3 );
  462. } );
  463. it( 'should do not move if the condition is false', () => {
  464. const walker = new TreeWalker( {
  465. startPosition: Position._createAt( paragraph, 1 )
  466. } );
  467. walker.skip( () => false );
  468. expect( walker.position.parent ).to.equal( paragraph );
  469. expect( walker.position.offset ).to.equal( 1 );
  470. } );
  471. it( 'should move to the end if the condition is true', () => {
  472. const walker = new TreeWalker( {
  473. startPosition: Position._createAt( paragraph, 1 )
  474. } );
  475. walker.skip( () => true );
  476. expect( walker.position.parent ).to.equal( rootEnding.parent );
  477. expect( walker.position.offset ).to.equal( rootEnding.offset );
  478. } );
  479. } );
  480. describe( 'backward treewalker', () => {
  481. it( 'should jump over all text nodes', () => {
  482. const walker = new TreeWalker( {
  483. startPosition: Position._createAt( paragraph, 3 ),
  484. direction: 'backward'
  485. } );
  486. walker.skip( value => value.type == 'text' );
  487. expect( walker.position.parent ).to.equal( paragraph );
  488. expect( walker.position.offset ).to.equal( 0 );
  489. } );
  490. it( 'should do not move if the condition is false', () => {
  491. const walker = new TreeWalker( {
  492. startPosition: Position._createAt( paragraph, 1 ),
  493. direction: 'backward'
  494. } );
  495. walker.skip( () => false );
  496. expect( walker.position.parent ).to.equal( paragraph );
  497. expect( walker.position.offset ).to.equal( 1 );
  498. } );
  499. it( 'should move to the end if the condition is true', () => {
  500. const walker = new TreeWalker( {
  501. startPosition: Position._createAt( paragraph, 1 ),
  502. direction: 'backward'
  503. } );
  504. walker.skip( () => true );
  505. expect( walker.position.parent ).to.equal( rootBeginning.parent );
  506. expect( walker.position.offset ).to.equal( rootBeginning.offset );
  507. } );
  508. } );
  509. } );
  510. } );
  511. function expectValue( value, expected, options ) {
  512. expect( value.type ).to.equal( expected.type );
  513. if ( value.type == 'text' ) {
  514. expectText( value, expected, options );
  515. } else if ( value.type == 'elementStart' ) {
  516. expectStart( value, expected, options );
  517. } else if ( value.type == 'elementEnd' ) {
  518. expectEnd( value, expected, options );
  519. }
  520. }
  521. function expectText( value, expected, options = {} ) {
  522. let previousPosition, nextPosition;
  523. expect( value.item.data ).to.equal( expected.data );
  524. expect( Array.from( value.item.getAttributes() ) ).to.deep.equal( expected.attrs );
  525. expect( value.length ).to.equal( value.item.data.length );
  526. if ( options.direction == 'backward' ) {
  527. previousPosition = Position._createAfter( value.item );
  528. nextPosition = Position._createBefore( value.item );
  529. } else {
  530. previousPosition = Position._createBefore( value.item );
  531. nextPosition = Position._createAfter( value.item );
  532. }
  533. expect( value.previousPosition ).to.deep.equal( previousPosition );
  534. expect( value.nextPosition ).to.deep.equal( nextPosition );
  535. }
  536. function expectStart( value, expected, options = {} ) {
  537. let previousPosition, nextPosition;
  538. expect( value.item ).to.equal( expected.item );
  539. expect( value.length ).to.equal( 1 );
  540. if ( options.direction == 'backward' ) {
  541. previousPosition = Position._createAfter( value.item );
  542. nextPosition = Position._createBefore( value.item );
  543. } else {
  544. previousPosition = Position._createBefore( value.item );
  545. nextPosition = Position._createAt( value.item, 0 );
  546. }
  547. if ( options.shallow ) {
  548. expect( value.previousPosition ).to.deep.equal( previousPosition );
  549. } else {
  550. expect( value.nextPosition ).to.deep.equal( nextPosition );
  551. }
  552. }
  553. function expectEnd( value, expected, options = {} ) {
  554. let previousPosition, nextPosition;
  555. expect( value.item ).to.equal( expected.item );
  556. expect( value.length ).to.be.undefined;
  557. if ( options.direction == 'backward' ) {
  558. previousPosition = Position._createAfter( value.item );
  559. nextPosition = Position._createAt( value.item, value.item.maxOffset );
  560. } else {
  561. previousPosition = Position._createAt( value.item, value.item.maxOffset );
  562. nextPosition = Position._createAfter( value.item );
  563. }
  564. expect( value.previousPosition ).to.deep.equal( previousPosition );
  565. expect( value.nextPosition ).to.deep.equal( nextPosition );
  566. }