2018-02-12 17:57:00 +00:00
|
|
|
/*!
|
|
|
|
* 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 ) {
|
2021-11-03 12:28:17 +00:00
|
|
|
var spacer = '<div class="ve-ui-diffElement-spacer">⋮</div>',
|
2018-04-28 13:46:23 +00:00
|
|
|
ref = function ( text, num ) {
|
2018-02-12 17:57:00 +00:00
|
|
|
var dataMw = {
|
|
|
|
name: 'ref',
|
|
|
|
body: { html: text }
|
2018-04-28 13:46:23 +00:00
|
|
|
// attrs doesn't get set in preview mode
|
2018-02-12 17:57:00 +00:00
|
|
|
};
|
2018-04-28 13:46:23 +00:00
|
|
|
|
2020-11-05 00:49:54 +00:00
|
|
|
return '<sup typeof="mw:Extension/ref" data-mw="' + JSON.stringify( dataMw ).replace( /"/g, '"' ) + '" class="mw-ref reference">' +
|
2018-02-12 17:57:00 +00:00
|
|
|
'<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:
|
2021-01-21 14:34:36 +00:00
|
|
|
spacer +
|
2018-02-12 17:57:00 +00:00
|
|
|
'<h2 data-diff-action="none">Notes</h2>' +
|
2022-01-19 14:22:40 +00:00
|
|
|
'<ol>' +
|
|
|
|
'<li value="1"><p data-diff-action="none">Foo</p></li>' +
|
|
|
|
'<li value="2">Bar<ins data-diff-action="insert"> ish</ins></li>' +
|
|
|
|
'<li value="3"><p data-diff-action="none">Baz</p></li>' +
|
|
|
|
'</ol>'
|
2018-02-12 17:57:00 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2021-11-03 12:28:17 +00:00
|
|
|
cases.forEach( function ( caseItem ) {
|
|
|
|
ve.test.utils.runDiffElementTest( assert, caseItem );
|
|
|
|
} );
|
2018-02-12 17:57:00 +00:00
|
|
|
|
|
|
|
} );
|