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 ) {
|
|
|
|
var i, len,
|
|
|
|
// 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
|
|
|
|
2018-02-12 17:57:00 +00:00
|
|
|
return '<sup typeof="mw:Extension/ref" data-mw="' + JSON.stringify( dataMw ).replace( /"/g, '"' ) + '" class="mw-ref">' +
|
|
|
|
'<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:
|
|
|
|
'<div class="ve-ui-diffElement-doc-child-change">' +
|
|
|
|
'<p>' +
|
|
|
|
ref( 'Foo', '1' ) +
|
|
|
|
'<span data-diff-action="change-remove">' +
|
2018-04-28 13:46:23 +00:00
|
|
|
ref( 'Bar', '2' ) +
|
2018-02-12 17:57:00 +00:00
|
|
|
'</span>' +
|
|
|
|
'<span data-diff-action="change-insert">' +
|
2018-04-28 13:46:23 +00:00
|
|
|
ref( 'Bar ish', '2' ) +
|
2018-02-12 17:57:00 +00:00
|
|
|
'</span>' +
|
|
|
|
ref( 'Baz', '3' ) +
|
|
|
|
'</p>' +
|
|
|
|
'</div>' +
|
|
|
|
'<h2 data-diff-action="none">Notes</h2>' +
|
2018-09-13 18:08:42 +00:00
|
|
|
'<div class="ve-ui-diffElement-doc-child-change" data-diff-move="null">' +
|
2018-02-12 17:57:00 +00:00
|
|
|
'<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 ] );
|
|
|
|
}
|
|
|
|
|
|
|
|
} );
|