mediawiki-extensions-Cite/modules/ve-cite/tests/ve.ui.DiffElement.test.js
Ed Sanders bae4a409a5 Update output of diff test
For I93a88abc8e9ecf38992b396c151215781057a6f4.

Change-Id: Ia743b0c37bbd33b95dd4824018ae59fbb6e45c3e
2023-03-08 15:52:02 +00:00

49 lines
1.6 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 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, '&quot;' ) + '" 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="{&quot;name&quot;:&quot;references&quot;}"></div>',
newDoc:
'<p>' + ref( 'Foo' ) + ref( 'Bar ish' ) + ref( 'Baz' ) + '</p>' +
'<h2>Notes</h2>' +
'<div typeof="mw:Extension/references" data-mw="{&quot;name&quot;:&quot;references&quot;}"></div>',
expected:
spacer +
'<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>'
}
];
cases.forEach( function ( caseItem ) {
ve.test.utils.runDiffElementTest( assert, caseItem );
} );
} );