jenkins-bot has submitted this change and it was merged. Change subject: Added unit tests for getRelativeOffset method ......................................................................
Added unit tests for getRelativeOffset method Change-Id: I45538f3e698229c003097c84edceac7ae4e4eb05 --- M modules/ve/test/ce/ve.ce.Document.test.js 1 file changed, 65 insertions(+), 0 deletions(-) Approvals: Catrope: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/ve/test/ce/ve.ce.Document.test.js b/modules/ve/test/ce/ve.ce.Document.test.js index d29e0ad..d95149f 100644 --- a/modules/ve/test/ce/ve.ce.Document.test.js +++ b/modules/ve/test/ce/ve.ce.Document.test.js @@ -17,3 +17,68 @@ assert.equalNodeSelection( cases[i].actual, cases[i].expected, cases[i].msg ); } } ); + +QUnit.test( 'getRelativeOffset', function ( assert ) { + var documentModel = ve.dm.example.createExampleDocument( 'alienData' ), + documentView = new ve.ce.Document( documentModel ), + tests = [ + { + direction: 1, + unit: 'character', + cases: [ + { input: 0, output: 3 }, + { input: 3, output: 4 }, + { input: 4, output: 6 }, + { input: 6, output: 7 }, + { input: 7, output: 10 } + ] + }, + { + direction: 1, + unit: 'word', + cases: [ + { input: 0, output: 3 }, + { input: 3, output: 4 }, + { input: 4, output: 6 }, + { input: 6, output: 7 }, + { input: 7, output: 10 } + ] + }, + { + direction: -1, + unit: 'character', + cases: [ + { input: 10, output: 7 }, + { input: 7, output: 6 }, + { input: 6, output: 4 }, + { input: 4, output: 3 }, + { input: 3, output: 0 } + ] + }, + { + direction: -1, + unit: 'word', + cases: [ + { input: 10, output: 7 }, + { input: 7, output: 6 }, + { input: 6, output: 4 }, + { input: 4, output: 3 }, + { input: 3, output: 0 } + ] + } + ], i, j, expectCount = 0; + for ( i = 0; i < tests.length; i++ ) { + for ( j = 0; j < tests[i].cases.length; j++ ) { + assert.equal( + documentView.getRelativeOffset( + tests[i].cases[j].input, + tests[i].direction, + tests[i].unit + ), + tests[i].cases[j].output + ); + } + expectCount += tests[i].cases.length; + } + QUnit.expect( expectCount ); +} ); -- To view, visit https://gerrit.wikimedia.org/r/60330 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I45538f3e698229c003097c84edceac7ae4e4eb05 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Inez <i...@wikia-inc.com> Gerrit-Reviewer: Catrope <roan.katt...@gmail.com> Gerrit-Reviewer: Inez <i...@wikia-inc.com> Gerrit-Reviewer: Trevor Parscal <tpars...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits