mediawiki-extensions-Visual.../modules/ve-mw/test/dm/ve.dm.MWConverter.test.js
Timo Tijhof 58c647e3ac Ensure we use our references to certain native or upstream methods
Checked:
 ve.cloneObject       (oo|OO).cloneObject
 ve.getObjectValues   (oo|OO).getObjectValues
 ve.getObjectKeys     Object.keys
 ve.compare           (oo|OO).compare
 ve.copy              (oo|OO).copy
 ve.isPlainObject     ($|jQuery).isPlainObject
 ve.isEmptyObject     ($|jQuery).isEmptyObject
 ve.isArray           Array.isArray
 ve.bind              ($|jQuery).proxy
 ve.indexOf           ($|jQuery).inArray
 ve.extendObject      ($|jQuery).extend

Fixed:
* ve.dm.MWBlockImageNode.js (added in Iebb2081de)
* ve.dm.MWInlineImageNode.js (aded in I62ec12a6b)
* ve.dm.MWConverter.test.js (added in I90273786a)
* ve.ui.MWMediaInsertDialog.js (added in Ia5ad9a8c0)
* ve.dm.MWTemplateSpecModel.js (added in Ic3eb66538)
* ve.init.mw.MobileViewTarget.js
* ve.init.mw.ViewPageTarget.js
* ve.init.mw.Target.js

Skipped:
* ve.init.mw.ViewPageTarget.init.js
  - Feature test (which is for the very references from ve.js
    being ensured in this commit).
  - Misc code using $.inArray (can't use ve.js yet since that
    isn't loaded yet there).

Change-Id: I73ae005d3692e871fdcaea938641558c0b98ec69
2014-02-20 22:30:29 +01:00

66 lines
1.4 KiB
JavaScript

/*!
* VisualEditor DataModel MediaWiki Converter tests.
*
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/*global mw */
QUnit.module( 've.dm.MWConverter' );
/* Tests */
function setMwConfig( newConfig ) {
var key, oldConfig = {};
for ( key in newConfig ) {
// Store orignal value
oldConfig[key] = mw.config.get( key );
// Override config setting
mw.config.set( key, newConfig[key] );
}
return oldConfig;
}
QUnit.test( 'getModelFromDom', function ( assert ) {
var msg, caseItem,
originalConfig,
cases = ve.dm.mwExample.domToDataCases;
QUnit.expect( ve.test.utils.countGetModelFromDomTests( cases ) );
for ( msg in cases ) {
caseItem = ve.copy( cases[msg] );
if ( caseItem.mwConfig ) {
originalConfig = setMwConfig( caseItem.mwConfig );
}
ve.test.utils.runGetModelFromDomTest( assert, caseItem );
if ( caseItem.mwConfig ) {
setMwConfig( originalConfig );
}
}
} );
QUnit.test( 'getDomFromModel', function ( assert ) {
var msg, caseItem,
originalConfig,
cases = ve.dm.mwExample.domToDataCases;
QUnit.expect( 2 * ve.getObjectKeys( cases ).length );
for ( msg in cases ) {
caseItem = ve.copy( cases[msg] );
if ( caseItem.mwConfig ) {
originalConfig = setMwConfig( caseItem.mwConfig );
}
ve.test.utils.runGetDomFromModelTest( assert, caseItem );
if ( caseItem.mwConfig ) {
setMwConfig( originalConfig );
}
}
} );