SurfaceFragment tests: Put isolateAndUnwrap tests in a loop

Change-Id: I8791da02a91f5ddc801290121031dde290883d6c
This commit is contained in:
Ed Sanders 2024-05-17 15:46:05 +01:00 committed by Esanders
parent 3bc0b9b1b8
commit 0a23f31227

View file

@ -10,22 +10,36 @@ QUnit.module( 've.dm.SurfaceFragment (MW)', ve.test.utils.newMwEnvironment() );
/* Tests */
QUnit.test( 'isolateAndUnwrap (MWheading)', ( assert ) => {
ve.test.utils.runIsolateTest( assert, 'mwHeading', new ve.Range( 12, 20 ), ( data ) => {
data.splice( 11, 0, { type: '/list' } );
data.splice( 12, 1 );
data.splice( 20, 1, { type: 'list', attributes: { style: 'bullet' } } );
}, ve.dm.mwExample.baseUri, 'isolating paragraph in list item "Item 2" for MWheading' );
ve.test.utils.runIsolateTest( assert, 'mwHeading', new ve.Range( 202, 212 ), ( data ) => {
data.splice( 201, 1,
{ type: '/list' }, { type: '/listItem' }, { type: '/list' }
);
data.splice( 214, 1,
{ type: 'list', attributes: { style: 'bullet' } },
{ type: 'listItem' },
{ type: 'list', attributes: { style: 'number' } }
);
}, ve.dm.mwExample.baseUri, 'isolating paragraph in list item "Nested 2" for MWheading' );
const cases = [
{
type: 'mwHeading',
range: new ve.Range( 12, 20 ),
expected: ( data ) => {
data.splice( 11, 0, { type: '/list' } );
data.splice( 12, 1 );
data.splice( 20, 1, { type: 'list', attributes: { style: 'bullet' } } );
},
base: ve.dm.mwExample.baseUri,
msg: 'isolating paragraph in list item "Item 2" for MWheading'
},
{
type: 'mwHeading',
range: new ve.Range( 202, 212 ),
expected: ( data ) => {
data.splice( 201, 1,
{ type: '/list' }, { type: '/listItem' }, { type: '/list' }
);
data.splice( 214, 1,
{ type: 'list', attributes: { style: 'bullet' } },
{ type: 'listItem' },
{ type: 'list', attributes: { style: 'number' } }
);
},
base: ve.dm.mwExample.baseUri,
msg: 'isolating paragraph in list item "Nested 2" for MWheading'
}
];
cases.forEach( ( caseItem ) => ve.test.utils.runIsolateTest( assert, caseItem ) );
} );
QUnit.test( 'insertContent (MWheading)', ( assert ) => {