Merge "Add/simplify assertions in transclusion outline related code"

This commit is contained in:
jenkins-bot 2021-08-30 15:34:22 +00:00 committed by Gerrit Code Review
commit 4297f44543
4 changed files with 20 additions and 15 deletions

View file

@ -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' );
} );

View file

@ -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 ) );
} );

View file

@ -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 );
} );

View file

@ -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 );
} );