jenkins-bot has submitted this change and it was merged. Change subject: dm.ElementLinearData.compareElements: Add a few missed test cases ......................................................................
dm.ElementLinearData.compareElements: Add a few missed test cases Use of "(!)" to express surprise/alarm/regret at expected behaviour that shouldn't be. Change-Id: I40fcebc1fda2ffe7e0465e7e76b72a655de36bbb --- M tests/dm/lineardata/ve.dm.ElementLinearData.test.js 1 file changed, 75 insertions(+), 1 deletion(-) Approvals: Catrope: Looks good to me, approved jenkins-bot: Verified diff --git a/tests/dm/lineardata/ve.dm.ElementLinearData.test.js b/tests/dm/lineardata/ve.dm.ElementLinearData.test.js index f545c08..6c0664f 100644 --- a/tests/dm/lineardata/ve.dm.ElementLinearData.test.js +++ b/tests/dm/lineardata/ve.dm.ElementLinearData.test.js @@ -1961,7 +1961,81 @@ } } ); -// TODO: ve.dm.ElementLinearData.static.compareElements +QUnit.test( 'compareElements', function ( assert ) { + var i, + cases = [ + { + a: '母', + b: '母', + comparison: true, + msg: 'Identical unannotated characters are identical' + }, + { + a: '다', + b: '가', + comparison: false, + msg: 'Non-identical unannotated characters are not identical' + }, + { + a: [ 'F', [ 0 ] ], + b: [ 'F', [ 0 ] ], + comparison: true, + msg: 'Identically-annotated identical characters are identical' + }, + { + a: [ 'F', [ 0 ] ], + b: [ 'F', [ 1 ] ], + comparison: true, + msg: 'Identical characters, non-identically-annotated, are identical (!)' + }, + { + a: 'F', + b: [ 'F', [ 0 ] ], + comparison: true, + msg: 'Identical characters, one annotated, one not, are identical (!)' + }, + { + a: { type: 'heading' }, + b: { type: 'heading' }, + comparison: true, + msg: 'Identical opening elements are identical' + }, + { + a: { type: 'heading' }, + b: { type: '/heading' }, + comparison: false, + msg: 'Matching opening and closing elements are not identical' + }, + { + a: { type: 'heading', attributes: { level: 3 } }, + b: { type: 'heading', attributes: { level: 3 } }, + comparison: true, + msg: 'Identical elements with identical attributes are identical' + }, + { + a: { type: 'heading', attributes: { level: 3 } }, + b: { type: 'heading', attributes: { level: 2 } }, + comparison: false, + msg: 'Identical elements with non-identical attributes are not identical' + }, + { + a: { type: 'heading', attributes: { level: 3 } }, + b: { type: 'heading' }, + comparison: false, + msg: 'Identical elements, one without an attribute, are not identical' + } + ]; + + QUnit.expect( cases.length ); + for ( i = 0; i < cases.length; i++ ) { + assert.equal( + ve.dm.ElementLinearData.static.compareElements( cases[ i ].a, cases[ i ].b ), + cases[ i ].comparison, + cases[ i ].msg + ); + } +} ); + // TODO: ve.dm.ElementLinearData#getAnnotationIndexesFromOffset // TODO: ve.dm.ElementLinearData#setAnnotationsAtOffset // TODO: ve.dm.ElementLinearData#getCharacterData -- To view, visit https://gerrit.wikimedia.org/r/269889 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I40fcebc1fda2ffe7e0465e7e76b72a655de36bbb Gerrit-PatchSet: 4 Gerrit-Project: VisualEditor/VisualEditor Gerrit-Branch: master Gerrit-Owner: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: Catrope <roan.katt...@gmail.com> Gerrit-Reviewer: Esanders <esand...@wikimedia.org> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits