| 1 |
'use strict'; |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
QUnit.module( 've.ui.DiffElement (Cite)' ); |
| 10 |
|
| 11 |
QUnit.test( 'Diffing', ( assert ) => { |
| 12 |
const spacer = '<div class="ve-ui-diffElement-spacer">⋮</div>', |
| 13 |
ref = function ( text, num ) { |
| 14 |
const dataMw = { |
| 15 |
name: 'ref', |
| 16 |
body: { html: text } |
| 17 |
|
| 18 |
}; |
| 19 |
|
| 20 |
return '<sup typeof="mw:Extension/ref" data-mw="' + JSON.stringify( dataMw ).replace( /"/g, '"' ) + '" class="mw-ref reference">' + |
| 21 |
'<a style="counter-reset: mw-Ref ' + num + ';"><span class="mw-reflink-text">[' + num + ']</span></a>' + |
| 22 |
'</sup>'; |
| 23 |
}, |
| 24 |
cases = [ |
| 25 |
{ |
| 26 |
msg: 'Simple ref change', |
| 27 |
oldDoc: ve.dm.example.singleLine` |
| 28 |
<p>${ ref( 'Foo' ) }${ ref( 'Bar' ) }${ ref( 'Baz' ) }</p> |
| 29 |
<h2>Notes</h2> |
| 30 |
<div typeof="mw:Extension/references" data-mw="{"name":"references"}"></div> |
| 31 |
`, |
| 32 |
newDoc: ve.dm.example.singleLine` |
| 33 |
<p>${ ref( 'Foo' ) }${ ref( 'Bar ish' ) }${ ref( 'Baz' ) }</p> |
| 34 |
<h2>Notes</h2> |
| 35 |
<div typeof="mw:Extension/references" data-mw="{"name":"references"}"></div> |
| 36 |
`, |
| 37 |
expected: ve.dm.example.singleLine` |
| 38 |
${ spacer } |
| 39 |
<h2 data-diff-action="none">Notes</h2> |
| 40 |
<ol> |
| 41 |
<li value="1"><p data-diff-action="none">Foo</p></li> |
| 42 |
<li value="2"><p>Bar<ins data-diff-action="insert"> ish</ins></p></li> |
| 43 |
<li value="3"><p data-diff-action="none">Baz</p></li> |
| 44 |
</ol> |
| 45 |
` |
| 46 |
} |
| 47 |
]; |
| 48 |
|
| 49 |
cases.forEach( ( caseItem ) => { |
| 50 |
ve.test.utils.runDiffElementTest( assert, caseItem ); |
| 51 |
} ); |
| 52 |
|
| 53 |
} ); |