From f14eba17ee31ff023fda3f109e7d3b4321eb7881 Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Sat, 11 Sep 2021 14:16:49 +0200 Subject: [PATCH] More assertions for ve.ui.MWTransclusionOutlineParameterWidget These additional assertions cover previously uncovered features. Change-Id: I6708ce2ef965f9ad81ec3d0aee163b6f2093344c --- ...TransclusionOutlineParameterWidget.test.js | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/modules/ve-mw/tests/ui/widgets/ve.ui.MWTransclusionOutlineParameterWidget.test.js b/modules/ve-mw/tests/ui/widgets/ve.ui.MWTransclusionOutlineParameterWidget.test.js index 9d7f173bc4..f7e0a88de1 100644 --- a/modules/ve-mw/tests/ui/widgets/ve.ui.MWTransclusionOutlineParameterWidget.test.js +++ b/modules/ve-mw/tests/ui/widgets/ve.ui.MWTransclusionOutlineParameterWidget.test.js @@ -3,26 +3,41 @@ QUnit.module( 've.ui.MWTransclusionOutlineParameterWidget' ); QUnit.test( 'interprets param with no attributes', ( assert ) => { const widget = new ve.ui.MWTransclusionOutlineParameterWidget( {} ); - assert.notOk( widget.checkbox.isDisabled() ); + assert.notOk( widget.isSelected() ); assert.notOk( widget.checkbox.isSelected() ); + assert.notOk( widget.checkbox.isDisabled() ); assert.strictEqual( widget.checkbox.getTitle(), null ); + + widget.setSelected( true ); + assert.ok( widget.isSelected(), 'can select item' ); + assert.ok( widget.checkbox.isSelected(), 'can select checkbox' ); } ); QUnit.test( 'interprets required param', ( assert ) => { const widget = new ve.ui.MWTransclusionOutlineParameterWidget( { required: true } ); - assert.ok( widget.checkbox.isDisabled() ); + assert.ok( widget.isSelected() ); assert.ok( widget.checkbox.isSelected() ); + assert.ok( widget.checkbox.isDisabled() ); assert.strictEqual( widget.checkbox.getTitle(), 'visualeditor-dialog-transclusion-required-parameter' ); + + widget.setSelected( false ); + assert.ok( widget.isSelected(), 'cannot unselect required item' ); + assert.ok( widget.checkbox.isSelected(), 'cannot unselect required checkbox' ); } ); QUnit.test( 'interprets selected param', ( assert ) => { const widget = new ve.ui.MWTransclusionOutlineParameterWidget( { selected: true } ); - assert.notOk( widget.checkbox.isDisabled() ); + assert.ok( widget.isSelected() ); assert.ok( widget.checkbox.isSelected() ); + assert.notOk( widget.checkbox.isDisabled() ); assert.strictEqual( widget.checkbox.getTitle(), null ); + + widget.setSelected( false ); + assert.notOk( widget.isSelected(), 'can unselect item' ); + assert.notOk( widget.checkbox.isSelected(), 'can unselect checkbox' ); } );