mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 10:59:56 +00:00
9392282bf2
This also fixes a mistake in the class where we forgot to disconnect event handlers when an element is removed from the list. This doesn't have much of a consequence, as the event flow is only in one direction, from the destroyed element up. This is not possible any more. Bug: T289560 Change-Id: I0bcc1d68c50b8cbdb033ef6692b34e2fc94e8d85
43 lines
1.8 KiB
JavaScript
43 lines
1.8 KiB
JavaScript
QUnit.module( 've.ui.MWTransclusionOutlineContainerWidget' );
|
|
|
|
QUnit.test( 'Constructor', ( assert ) => {
|
|
const widget = new ve.ui.MWTransclusionOutlineContainerWidget();
|
|
|
|
// eslint-disable-next-line no-jquery/no-class-state
|
|
assert.ok( widget.$element.hasClass( 've-ui-mwTransclusionOutlineContainerWidget' ) );
|
|
assert.deepEqual( widget.partWidgets, {} );
|
|
} );
|
|
|
|
QUnit.test( 'Supports all ve.dm.MWTransclusionPartModel subclasses', ( assert ) => {
|
|
const transclusion = new ve.dm.MWTransclusionModel(),
|
|
widget = new ve.ui.MWTransclusionOutlineContainerWidget();
|
|
|
|
widget.onReplacePart( null, new ve.dm.MWTemplateModel( transclusion, {} ) );
|
|
widget.onReplacePart( null, new ve.dm.MWTemplatePlaceholderModel( transclusion ) );
|
|
widget.onReplacePart( null, new ve.dm.MWTransclusionContentModel( transclusion ) );
|
|
|
|
assert.ok( widget.partWidgets.part_0 instanceof ve.ui.MWTransclusionOutlineTemplateWidget );
|
|
assert.ok( widget.partWidgets.part_1 instanceof ve.ui.MWTransclusionOutlinePlaceholderWidget );
|
|
assert.ok( widget.partWidgets.part_2 instanceof ve.ui.MWTransclusionOutlineWikitextWidget );
|
|
} );
|
|
|
|
QUnit.test( 'Basic functionality', ( assert ) => {
|
|
const transclusion = new ve.dm.MWTransclusionModel(),
|
|
part0 = new ve.dm.MWTransclusionContentModel( transclusion ),
|
|
part1 = new ve.dm.MWTransclusionContentModel( transclusion ),
|
|
widget = new ve.ui.MWTransclusionOutlineContainerWidget();
|
|
|
|
widget.onReplacePart();
|
|
assert.deepEqual( widget.partWidgets, {} );
|
|
|
|
widget.onReplacePart( null, part0 );
|
|
widget.onReplacePart( null, part1 );
|
|
assert.deepEqual( Object.keys( widget.partWidgets ), [ 'part_0', 'part_1' ] );
|
|
|
|
widget.onReplacePart( part0 );
|
|
assert.deepEqual( Object.keys( widget.partWidgets ), [ 'part_1' ] );
|
|
|
|
widget.clear();
|
|
assert.deepEqual( widget.partWidgets, {} );
|
|
} );
|