mediawiki-extensions-Visual.../modules/ve-mw/tests/ui/ve.ui.DiffElement.test.js
Bartosz Dziewoński e40b73ef57 Update VE core submodule to master (b7ff5aac0)
New changes:
2201b350c Localisation updates from https://translatewiki.net.
da74736c1 Remove unused test code
d1b016e90 Minor test tweaks
551de4f0c Specify document base URLs in more test cases

Local changes:
* Specify document base URLs in more test cases

Change-Id: I0e301bef38d97fa2234aa901c787360d9fbde8a3
2023-01-23 15:57:59 +01:00

60 lines
2.2 KiB
JavaScript

/*!
* VisualEditor MW-specific DiffElement tests.
*
* @copyright 2011-2020 VisualEditor Team and others; see http://ve.mit-license.org
*/
QUnit.module( 've.ui.DiffElement (MW)', ve.test.utils.newMwEnvironment() );
QUnit.test( 'Diffing', ( assert ) => {
const
cases = [
{
msg: 'Change template param',
oldDoc: ve.test.utils.addBaseTag(
ve.dm.mwExample.MWTransclusion.blockOpen + ve.dm.mwExample.MWTransclusion.blockContent,
ve.dm.example.baseUri
),
newDoc: ve.test.utils.addBaseTag(
ve.dm.mwExample.MWTransclusion.blockOpenModified + ve.dm.mwExample.MWTransclusion.blockContent,
ve.dm.example.baseUri
),
expected:
( ve.dm.mwExample.MWTransclusion.blockOpenModified + ve.dm.mwExample.MWTransclusion.blockContent )
// FIXME: Use DOM modification instead of string replaces
.replace( /#mwt1"/g, '#mwt1" data-diff-action="structural-change" data-diff-id="0"' ),
expectedDescriptions: [
'<div>visualeditor-changedesc-mwtransclusion</div>' +
'<div><ul><li>visualeditor-changedesc-changed-diff,1,<span>Hello, <del>world</del><ins>globe</ins>!</span></li></ul></div>'
]
},
{
msg: 'Changed width of block image',
oldDoc: ve.test.utils.addBaseTag(
ve.dm.mwExample.MWBlockImage.html,
ve.dm.example.baseUri
),
newDoc: ve.test.utils.addBaseTag(
ve.dm.mwExample.MWBlockImage.html.replace( 'width="1"', 'width="3"' ),
ve.dm.example.baseUri
),
expected:
ve.dm.mwExample.MWBlockImage.html
// FIXME: Use DOM modification instead of string replaces
.replace( 'width="1"', 'width="3"' )
.replace( 'href="./Foo"', 'href="' + new URL( './Foo', ve.dm.example.baseUri ) + '"' )
.replace( 'foobar"', 'foobar" data-diff-action="structural-change" data-diff-id="0"' ),
expectedDescriptions: [
'<div>visualeditor-changedesc-image-size,' +
'<del>1visualeditor-dimensionswidget-times2visualeditor-dimensionswidget-px</del>,' +
'<ins>3visualeditor-dimensionswidget-times2visualeditor-dimensionswidget-px</ins></div>'
]
}
];
for ( let i = 0; i < cases.length; i++ ) {
ve.test.utils.runDiffElementTest( assert, cases[ i ] );
}
} );