mediawiki-extensions-Visual.../modules/ve-mw/test/dm/ve.dm.Converter.test.js
Timo Tijhof 792e7db351 ve.dm.Converter.test: Use teardown to restore mw.config instead of ad-hoc
Follows-up I90273786ac186d.

QUnit.newMwEnvironment() is a utility provided by MediaWiki core
that returns an object with 'setup' and 'teardown' that automatically
provides a new sandboxed mw.config before each test and restores
the original after each test.

Change-Id: I24ac5d8be278df7070093fb84bcbe3720be18791
2014-06-11 18:19:53 +02:00

43 lines
1 KiB
JavaScript

/*!
* VisualEditor DataModel MediaWiki-specific 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.Converter', QUnit.newMwEnvironment() );
QUnit.test( 'getModelFromDom', function ( assert ) {
var msg, caseItem,
cases = ve.dm.mwExample.domToDataCases;
QUnit.expect( ve.test.utils.countGetModelFromDomTests( cases ) );
for ( msg in cases ) {
caseItem = ve.copy( cases[msg] );
if ( caseItem.mwConfig ) {
mw.config.set( caseItem.mwConfig );
}
ve.test.utils.runGetModelFromDomTest( assert, caseItem, msg );
}
} );
QUnit.test( 'getDomFromModel', function ( assert ) {
var msg, caseItem,
cases = ve.dm.mwExample.domToDataCases;
QUnit.expect( 2 * ve.getObjectKeys( cases ).length );
for ( msg in cases ) {
caseItem = ve.copy( cases[msg] );
if ( caseItem.mwConfig ) {
mw.config.set( caseItem.mwConfig );
}
ve.test.utils.runGetDomFromModelTest( assert, caseItem, msg );
}
} );