2013-06-26 21:18:39 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor DataModel MediaWiki Converter tests.
|
|
|
|
*
|
2014-01-05 12:05:05 +00:00
|
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
2013-06-26 21:18:39 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2014-01-15 03:15:37 +00:00
|
|
|
/*global mw */
|
|
|
|
|
2013-06-26 21:18:39 +00:00
|
|
|
QUnit.module( 've.dm.MWConverter' );
|
|
|
|
|
|
|
|
/* Tests */
|
|
|
|
|
2014-01-15 03:15:37 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-12-04 17:37:50 +00:00
|
|
|
QUnit.test( 'getModelFromDom', function ( assert ) {
|
2014-01-15 03:15:37 +00:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|
2013-06-26 21:18:39 +00:00
|
|
|
} );
|
|
|
|
|
2013-11-25 15:10:49 +00:00
|
|
|
QUnit.test( 'getDomFromModel', function ( assert ) {
|
2014-01-15 03:15:37 +00:00
|
|
|
var msg, caseItem,
|
|
|
|
originalConfig,
|
|
|
|
cases = ve.dm.mwExample.domToDataCases;
|
|
|
|
|
2014-02-20 21:30:29 +00:00
|
|
|
QUnit.expect( 2 * ve.getObjectKeys( cases ).length );
|
2014-01-15 03:15:37 +00:00
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|
2013-06-26 21:18:39 +00:00
|
|
|
} );
|