mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-18 17:50:43 +00:00
c763fb5cc3
This means that all reference nodes are treated as comparable in the diff (provided they are in the same group) so will not show up in the article diff if their index changes. Changes to the reference list are already handled separately by the visual diff. Bug: T170235 Change-Id: I8c26686d7b2fe3bf91af7d4dcab1caf3247dbe47
56 lines
1.8 KiB
JavaScript
56 lines
1.8 KiB
JavaScript
/*!
|
|
* VisualEditor Cite-specific DiffElement tests.
|
|
*
|
|
* @copyright 2011-2018 VisualEditor Team and others; see http://ve.mit-license.org
|
|
*/
|
|
|
|
QUnit.module( 've.ui.DiffElement (Cite)' );
|
|
|
|
QUnit.test( 'Diffing', function ( assert ) {
|
|
var i, len,
|
|
spacer = '<div class="ve-ui-diffElement-spacer">⋮</div>',
|
|
ref = function ( text, num ) {
|
|
var dataMw = {
|
|
name: 'ref',
|
|
body: { html: text }
|
|
// attrs doesn't get set in preview mode
|
|
};
|
|
|
|
return '<sup typeof="mw:Extension/ref" data-mw="' + JSON.stringify( dataMw ).replace( /"/g, '"' ) + '" class="mw-ref reference">' +
|
|
'<a style="counter-reset: mw-Ref ' + num + ';"><span class="mw-reflink-text">[' + num + ']</span></a>' +
|
|
'</sup>';
|
|
},
|
|
cases = [
|
|
{
|
|
msg: 'Simple ref change',
|
|
oldDoc:
|
|
'<p>' + ref( 'Foo' ) + ref( 'Bar' ) + ref( 'Baz' ) + '</p>' +
|
|
'<h2>Notes</h2>' +
|
|
'<div typeof="mw:Extension/references" data-mw="{"name":"references"}"></div>',
|
|
newDoc:
|
|
'<p>' + ref( 'Foo' ) + ref( 'Bar ish' ) + ref( 'Baz' ) + '</p>' +
|
|
'<h2>Notes</h2>' +
|
|
'<div typeof="mw:Extension/references" data-mw="{"name":"references"}"></div>',
|
|
expected:
|
|
spacer +
|
|
'<h2 data-diff-action="none">Notes</h2>' +
|
|
'<div class="ve-ui-diffElement-doc-child-change">' +
|
|
'<ol start="1">' +
|
|
'<li><p data-diff-action="none">Foo</p></li>' +
|
|
'</ol>' +
|
|
'<ol start="2">' +
|
|
'<li><div class="ve-ui-diffElement-doc-child-change">Bar<ins data-diff-action="insert"> ish</ins></div></li>' +
|
|
'</ol>' +
|
|
'<ol start="3">' +
|
|
'<li><p data-diff-action="none">Baz</p></li>' +
|
|
'</ol>' +
|
|
'</div>'
|
|
}
|
|
];
|
|
|
|
for ( i = 0, len = cases.length; i < len; i++ ) {
|
|
ve.test.utils.runDiffElementTest( assert, cases[ i ] );
|
|
}
|
|
|
|
} );
|