mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 19:09:29 +00:00
1f74985894
New changes: 479b50059 Localisation updates from https://translatewiki.net. c595d8ab0 Metion task related to Firefox hack 0a160fac2 Don't trust selections from the server d796f3db5 rebaser: Update dependencies b097dfaad ve.dm.Transaction: Don't translate offsets inside annotate-only replacements eadee0343 FragmentWindow: Replace previousSelection with initialFragment 561e88158 Use ve.dm.example.imgSrc everywhere d1dceab31 DesktopContext: Remove onModelSelect event 85947ac55 Pause synchronizer while staging 9a4dd169d Catch various out-of-bounds exceptions 341114afc Remove CE HTML from DM html test fixture 5d3a673e0 ve.ce.Document test: Add src to test image 182ac338e Evalutate fragment selection after staging e032fa161 rebaser: Drop document opacity while paused Change-Id: Id551ee2e6510610b8f2e12cf77ce3c8429700872
81 lines
2.4 KiB
JavaScript
81 lines
2.4 KiB
JavaScript
/*!
|
|
* VisualEditor DataModel MediaWiki-specific SurfaceFragment tests.
|
|
*
|
|
* @copyright 2011-2019 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
QUnit.module( 've.dm.SurfaceFragment (MW)', ve.test.utils.mwEnvironment );
|
|
|
|
/* Tests */
|
|
|
|
QUnit.test( 'isolateAndUnwrap (MWheading)', function ( assert ) {
|
|
ve.test.utils.runIsolateTest( assert, 'mwHeading', new ve.Range( 12, 20 ), function ( data ) {
|
|
data.splice( 11, 0, { type: '/list' } );
|
|
data.splice( 12, 1 );
|
|
data.splice( 20, 1, { type: 'list', attributes: { style: 'bullet' } } );
|
|
}, 'isolating paragraph in list item "Item 2" for MWheading' );
|
|
|
|
ve.test.utils.runIsolateTest( assert, 'mwHeading', new ve.Range( 202, 212 ), function ( 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' } }
|
|
);
|
|
}, 'isolating paragraph in list item "Nested 2" for MWheading' );
|
|
} );
|
|
|
|
QUnit.test( 'insertContent (MWheading)', function ( assert ) {
|
|
var doc = new ve.dm.Document( [
|
|
{ type: 'list', attributes: { style: 'bullet' } },
|
|
{ type: 'listItem' },
|
|
{ type: 'paragraph' },
|
|
'a',
|
|
'b',
|
|
{ type: '/paragraph' },
|
|
{ type: '/listItem' },
|
|
{ type: '/list' },
|
|
{ type: 'internalList' },
|
|
{ type: '/internalList' }
|
|
] ),
|
|
surface = new ve.dm.Surface( doc ),
|
|
fragment = surface.getLinearFragment( new ve.Range( 4, 4 ) ),
|
|
headingData = [ { type: 'mwHeading', attributes: { level: 3 } }, 'x', { type: '/mwHeading' } ];
|
|
|
|
fragment.insertContent( headingData );
|
|
assert.deepEqual(
|
|
doc.getData( new ve.Range( 3, 14 ) ),
|
|
[
|
|
'a',
|
|
{ type: '/paragraph' },
|
|
{ type: '/listItem' },
|
|
{ type: '/list' },
|
|
{ type: 'mwHeading', attributes: { level: 3 } },
|
|
'x',
|
|
{ type: '/mwHeading' },
|
|
{ type: 'list', attributes: { style: 'bullet' } },
|
|
{ type: 'listItem' },
|
|
{ type: 'paragraph' },
|
|
'b'
|
|
],
|
|
'inserting a mwheading into a listitem should isolate it from the list'
|
|
);
|
|
|
|
surface.undo();
|
|
fragment = surface.getLinearFragment( new ve.Range( 8, 8 ) );
|
|
fragment.insertContent( headingData );
|
|
assert.deepEqual(
|
|
doc.getData( new ve.Range( 7, 11 ) ),
|
|
[
|
|
{ type: '/list' },
|
|
{ type: 'mwHeading', attributes: { level: 3 } },
|
|
'x',
|
|
{ type: '/mwHeading' }
|
|
],
|
|
'inserting a mwheading to the document root should not add any extra closing elements'
|
|
);
|
|
} );
|