/*! * Parsoid utilities tests. * * @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt * @license The MIT License (MIT); see LICENSE.txt */ QUnit.module( 've.utils.parsoid', ve.test.utils.newMwEnvironment() ); QUnit.test( 'reduplicateStyles/deduplicateStyles', ( assert ) => { // Test cases based on this page and the templates there: // https://en.wikipedia.beta.wmflabs.org/wiki/Table_templated const stylesCases = [ { msg: 'styles are deduplicated', deduplicated: `
Hello
Goodbye
Welcome
`, reduplicated: `
Hello
Goodbye
Welcome
` }, { msg: 'styles in fosterable positions are NOT deduplicated, but they are emptied', deduplicated: `
Hello
Goodbye
Welcome
`, reduplicated: `
Hello
Goodbye
Welcome
` } ]; stylesCases.forEach( ( caseItem ) => { const doc = ve.parseXhtml( caseItem.deduplicated ); // Test that we can re-duplicate styles, which were de-duplicated in Parsoid HTML mw.libs.ve.reduplicateStyles( doc.body ); assert.equalDomElement( doc.body, ve.parseXhtml( caseItem.reduplicated ).body, caseItem.msg + ' (reduplicated)' ); // Test that we can de-duplicate styles again, producing a result identical to the Parsoid HTML mw.libs.ve.deduplicateStyles( doc.body ); assert.equalDomElement( doc.body, ve.parseXhtml( caseItem.deduplicated ).body, caseItem.msg + ' (deduplicated)' ); } ); } );