mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 06:46:26 +00:00
b0cfb82369
Also update MWConverter.test.js for test util changes. New changes: 863288b Update OOjs UI to v0.1.0-pre (af97c1caec) 0bb2404 Refactor converter test utils to run single test cases Change-Id: I90273786ac186df3eec13270f94d655b605bfdc4
66 lines
1.4 KiB
JavaScript
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 * Object.keys( 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 );
|
|
}
|
|
}
|
|
} );
|