2013-06-26 21:18:39 +00:00
|
|
|
/*!
|
2014-03-03 14:10:06 +00:00
|
|
|
* VisualEditor DataModel MediaWiki-specific Converter tests.
|
2013-06-26 21:18:39 +00:00
|
|
|
*
|
2015-01-08 23:54:03 +00:00
|
|
|
* @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
|
2013-06-26 21:18:39 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2015-02-13 19:46:28 +00:00
|
|
|
QUnit.module( 've.dm.Converter (MW)', QUnit.newMwEnvironment() );
|
2014-01-15 03:15:37 +00:00
|
|
|
|
2015-02-17 13:03:59 +00:00
|
|
|
ve.test.utils.modelRegistrySetup = function () {
|
|
|
|
ve.dm.modelRegistry.register( ve.dm.MWHeadingNode );
|
|
|
|
ve.dm.modelRegistry.register( ve.dm.MWPreformattedNode );
|
|
|
|
ve.dm.modelRegistry.register( ve.dm.MWTableNode );
|
|
|
|
};
|
|
|
|
|
|
|
|
ve.test.utils.modelRegistryTeardown = function () {
|
|
|
|
ve.dm.modelRegistry.register( ve.dm.HeadingNode );
|
|
|
|
ve.dm.modelRegistry.register( ve.dm.PreformattedNode );
|
|
|
|
ve.dm.modelRegistry.register( ve.dm.TableNode );
|
|
|
|
};
|
|
|
|
|
2013-12-04 17:37:50 +00:00
|
|
|
QUnit.test( 'getModelFromDom', function ( assert ) {
|
2014-01-15 03:15:37 +00:00
|
|
|
var msg, caseItem,
|
|
|
|
cases = ve.dm.mwExample.domToDataCases;
|
|
|
|
|
|
|
|
QUnit.expect( ve.test.utils.countGetModelFromDomTests( cases ) );
|
|
|
|
|
2015-02-17 13:03:59 +00:00
|
|
|
ve.test.utils.modelRegistrySetup();
|
2014-01-15 03:15:37 +00:00
|
|
|
for ( msg in cases ) {
|
|
|
|
caseItem = ve.copy( cases[msg] );
|
|
|
|
if ( caseItem.mwConfig ) {
|
2014-06-11 16:19:53 +00:00
|
|
|
mw.config.set( caseItem.mwConfig );
|
2014-01-15 03:15:37 +00:00
|
|
|
}
|
|
|
|
|
2014-03-12 23:02:41 +00:00
|
|
|
ve.test.utils.runGetModelFromDomTest( assert, caseItem, msg );
|
2014-01-15 03:15:37 +00:00
|
|
|
}
|
2015-02-17 13:03:59 +00:00
|
|
|
ve.test.utils.modelRegistryTeardown();
|
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,
|
|
|
|
cases = ve.dm.mwExample.domToDataCases;
|
|
|
|
|
2015-03-10 12:50:42 +00:00
|
|
|
QUnit.expect( 3 * Object.keys( cases ).length );
|
2014-01-15 03:15:37 +00:00
|
|
|
|
2015-02-17 13:03:59 +00:00
|
|
|
ve.test.utils.modelRegistrySetup();
|
2014-01-15 03:15:37 +00:00
|
|
|
for ( msg in cases ) {
|
|
|
|
caseItem = ve.copy( cases[msg] );
|
|
|
|
if ( caseItem.mwConfig ) {
|
2014-06-11 16:19:53 +00:00
|
|
|
mw.config.set( caseItem.mwConfig );
|
2014-01-15 03:15:37 +00:00
|
|
|
}
|
|
|
|
|
2014-03-12 23:02:41 +00:00
|
|
|
ve.test.utils.runGetDomFromModelTest( assert, caseItem, msg );
|
2014-01-15 03:15:37 +00:00
|
|
|
}
|
2015-02-17 13:03:59 +00:00
|
|
|
ve.test.utils.modelRegistryTeardown();
|
2013-06-26 21:18:39 +00:00
|
|
|
} );
|