2023-08-21 08:08:23 +00:00
|
|
|
'use strict';
|
|
|
|
|
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 ) {
|
2023-08-21 08:08:23 +00:00
|
|
|
const spacer = '<div class="ve-ui-diffElement-spacer">⋮</div>',
|
2018-04-28 13:46:23 +00:00
|
|
|
ref = function ( text, num ) {
|
2023-08-21 08:08:23 +00:00
|
|
|
const dataMw = {
|
2018-02-12 17:57:00 +00:00
|
|
|
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',
|
2023-06-01 14:46:00 +00:00
|
|
|
oldDoc: ve.dm.example.singleLine`
|
2023-12-12 13:21:07 +00:00
|
|
|
<p>${ ref( 'Foo' ) }${ ref( 'Bar' ) }${ ref( 'Baz' ) }</p>
|
2023-06-01 14:46:00 +00:00
|
|
|
<h2>Notes</h2>
|
|
|
|
<div typeof="mw:Extension/references" data-mw="{"name":"references"}"></div>
|
|
|
|
`,
|
|
|
|
newDoc: ve.dm.example.singleLine`
|
2023-12-12 13:21:07 +00:00
|
|
|
<p>${ ref( 'Foo' ) }${ ref( 'Bar ish' ) }${ ref( 'Baz' ) }</p>
|
2023-06-01 14:46:00 +00:00
|
|
|
<h2>Notes</h2>
|
|
|
|
<div typeof="mw:Extension/references" data-mw="{"name":"references"}"></div>
|
|
|
|
`,
|
|
|
|
expected: ve.dm.example.singleLine`
|
2023-12-12 13:21:07 +00:00
|
|
|
${ spacer }
|
2023-06-01 14:46:00 +00:00
|
|
|
<h2 data-diff-action="none">Notes</h2>
|
|
|
|
<ol>
|
|
|
|
<li value="1"><p data-diff-action="none">Foo</p></li>
|
|
|
|
<li value="2"><p>Bar<ins data-diff-action="insert"> ish</ins></p></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
|
|
|
|
|
|
|
} );
|