mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
Merge "Add/simplify assertions in transclusion outline related code"
This commit is contained in:
commit
4297f44543
|
@ -43,7 +43,7 @@
|
|||
|
||||
assert.strictEqual( items.length, 2 );
|
||||
assert.strictEqual( items[ 0 ].getData().name, 'abbr' );
|
||||
assert.strictEqual( items[ 0 ].getData().isUnknown, true );
|
||||
assert.ok( items[ 0 ].getData().isUnknown );
|
||||
assert.strictEqual( items[ 1 ].getData().name, 'abbreviation' );
|
||||
} );
|
||||
|
||||
|
|
|
@ -56,15 +56,17 @@ QUnit.test( 'Adding and moving parts to specific positions', ( assert ) => {
|
|||
// Note this is just a map and doesn't reflect the order in the UI
|
||||
assert.deepEqual( Object.keys( widget.partWidgets ), [ 'part_0', 'part_1', 'part_2' ] );
|
||||
|
||||
assert.ok( widget.$element.children().eq( 0 ).is( widget.partWidgets.part_1.$element ) );
|
||||
assert.ok( widget.$element.children().eq( 1 ).is( widget.partWidgets.part_2.$element ) );
|
||||
assert.ok( widget.$element.children().eq( 2 ).is( widget.partWidgets.part_0.$element ) );
|
||||
let $items = widget.$element.children();
|
||||
assert.ok( $items.eq( 0 ).is( widget.partWidgets.part_1.$element ) );
|
||||
assert.ok( $items.eq( 1 ).is( widget.partWidgets.part_2.$element ) );
|
||||
assert.ok( $items.eq( 2 ).is( widget.partWidgets.part_0.$element ) );
|
||||
|
||||
// This bypasses all logic in ve.dm.MWTransclusionModel, effectively making it a mock.
|
||||
transclusion.parts = [ part2, part0, part1 ];
|
||||
widget.onTransclusionModelChange( transclusion );
|
||||
|
||||
assert.ok( widget.$element.children().eq( 0 ).is( widget.partWidgets.part_2.$element ) );
|
||||
assert.ok( widget.$element.children().eq( 1 ).is( widget.partWidgets.part_0.$element ) );
|
||||
assert.ok( widget.$element.children().eq( 2 ).is( widget.partWidgets.part_1.$element ) );
|
||||
$items = widget.$element.children();
|
||||
assert.ok( $items.eq( 0 ).is( widget.partWidgets.part_2.$element ) );
|
||||
assert.ok( $items.eq( 1 ).is( widget.partWidgets.part_0.$element ) );
|
||||
assert.ok( $items.eq( 2 ).is( widget.partWidgets.part_1.$element ) );
|
||||
} );
|
||||
|
|
|
@ -3,16 +3,16 @@ QUnit.module( 've.ui.MWTransclusionOutlineParameterWidget' );
|
|||
QUnit.test( 'interprets param with no attributes', ( assert ) => {
|
||||
const widget = new ve.ui.MWTransclusionOutlineParameterWidget( {} );
|
||||
|
||||
assert.strictEqual( widget.checkbox.isDisabled(), false );
|
||||
assert.strictEqual( widget.checkbox.isSelected(), false );
|
||||
assert.notOk( widget.checkbox.isDisabled() );
|
||||
assert.notOk( widget.checkbox.isSelected() );
|
||||
assert.strictEqual( widget.checkbox.getTitle(), null );
|
||||
} );
|
||||
|
||||
QUnit.test( 'interprets required param', ( assert ) => {
|
||||
const widget = new ve.ui.MWTransclusionOutlineParameterWidget( { required: true } );
|
||||
|
||||
assert.strictEqual( widget.checkbox.isDisabled(), true );
|
||||
assert.strictEqual( widget.checkbox.isSelected(), true );
|
||||
assert.ok( widget.checkbox.isDisabled() );
|
||||
assert.ok( widget.checkbox.isSelected() );
|
||||
assert.strictEqual(
|
||||
widget.checkbox.getTitle(),
|
||||
'visualeditor-dialog-transclusion-required-parameter'
|
||||
|
@ -22,7 +22,7 @@ QUnit.test( 'interprets required param', ( assert ) => {
|
|||
QUnit.test( 'interprets selected param', ( assert ) => {
|
||||
const widget = new ve.ui.MWTransclusionOutlineParameterWidget( { selected: true } );
|
||||
|
||||
assert.strictEqual( widget.checkbox.isDisabled(), false );
|
||||
assert.strictEqual( widget.checkbox.isSelected(), true );
|
||||
assert.notOk( widget.checkbox.isDisabled() );
|
||||
assert.ok( widget.checkbox.isSelected() );
|
||||
assert.strictEqual( widget.checkbox.getTitle(), null );
|
||||
} );
|
||||
|
|
|
@ -10,6 +10,8 @@ QUnit.test( 'Constructor', ( assert ) => {
|
|||
widget.$element.find( '.ve-ui-mwTransclusionOutlineButtonWidget' ).text(),
|
||||
'Example'
|
||||
);
|
||||
assert.notOk( widget.searchWidget.isVisible() );
|
||||
assert.notOk( widget.infoWidget.isVisible() );
|
||||
} );
|
||||
|
||||
QUnit.test( 'insertCheckboxAtCanonicalPosition()', ( assert ) => {
|
||||
|
@ -76,7 +78,7 @@ QUnit.test( 'filterParameters() on an empty template', ( assert ) => {
|
|||
} );
|
||||
|
||||
widget.filterParameters( '' );
|
||||
assert.strictEqual( widget.infoWidget.isVisible(), true );
|
||||
assert.ok( widget.infoWidget.isVisible() );
|
||||
assert.strictEqual( eventsFired, 1 );
|
||||
} );
|
||||
|
||||
|
@ -111,7 +113,8 @@ QUnit.test( 'filterParameters() considers everything from the spec', ( assert )
|
|||
}
|
||||
} );
|
||||
|
||||
assert.ok( widget.searchWidget.isVisible() );
|
||||
widget.filterParameters( ' A ' );
|
||||
assert.strictEqual( widget.infoWidget.isVisible(), false );
|
||||
assert.notOk( widget.infoWidget.isVisible() );
|
||||
assert.strictEqual( eventsFired, 1 );
|
||||
} );
|
||||
|
|
Loading…
Reference in a new issue