2021-08-25 08:31:34 +00:00
|
|
|
QUnit.module( 've.ui.MWTransclusionOutlineParameterWidget' );
|
2021-06-18 09:48:33 +00:00
|
|
|
|
2021-08-25 08:31:34 +00:00
|
|
|
QUnit.test( 'interprets param with no attributes', ( assert ) => {
|
2021-08-25 09:29:23 +00:00
|
|
|
const widget = new ve.ui.MWTransclusionOutlineParameterWidget( {} );
|
2021-06-18 09:48:33 +00:00
|
|
|
|
2021-11-02 01:27:09 +00:00
|
|
|
assert.false( widget.isSelected() );
|
|
|
|
assert.false( widget.checkbox.isSelected() );
|
|
|
|
assert.false( widget.checkbox.isDisabled() );
|
2021-08-25 09:29:23 +00:00
|
|
|
assert.strictEqual( widget.checkbox.getTitle(), null );
|
2021-09-11 12:16:49 +00:00
|
|
|
|
|
|
|
widget.setSelected( true );
|
2021-11-02 01:27:09 +00:00
|
|
|
assert.true( widget.isSelected(), 'can select item' );
|
|
|
|
assert.true( widget.checkbox.isSelected(), 'can select checkbox' );
|
2021-08-25 08:31:34 +00:00
|
|
|
} );
|
2021-06-18 09:48:33 +00:00
|
|
|
|
2021-08-25 08:31:34 +00:00
|
|
|
QUnit.test( 'interprets required param', ( assert ) => {
|
2021-08-25 09:29:23 +00:00
|
|
|
const widget = new ve.ui.MWTransclusionOutlineParameterWidget( { required: true } );
|
2021-06-18 09:48:33 +00:00
|
|
|
|
2021-11-02 01:27:09 +00:00
|
|
|
assert.true( widget.isSelected() );
|
|
|
|
assert.true( widget.checkbox.isSelected() );
|
|
|
|
assert.true( widget.checkbox.isDisabled() );
|
2021-08-25 09:29:23 +00:00
|
|
|
assert.strictEqual(
|
|
|
|
widget.checkbox.getTitle(),
|
|
|
|
'visualeditor-dialog-transclusion-required-parameter'
|
|
|
|
);
|
2021-09-11 12:16:49 +00:00
|
|
|
|
|
|
|
widget.setSelected( false );
|
2021-11-02 01:27:09 +00:00
|
|
|
assert.true( widget.isSelected(), 'cannot unselect required item' );
|
|
|
|
assert.true( widget.checkbox.isSelected(), 'cannot unselect required checkbox' );
|
2021-08-25 08:31:34 +00:00
|
|
|
} );
|
2021-06-18 09:48:33 +00:00
|
|
|
|
2021-08-25 08:31:34 +00:00
|
|
|
QUnit.test( 'interprets selected param', ( assert ) => {
|
2021-08-25 09:29:23 +00:00
|
|
|
const widget = new ve.ui.MWTransclusionOutlineParameterWidget( { selected: true } );
|
2021-06-18 09:48:33 +00:00
|
|
|
|
2021-11-02 01:27:09 +00:00
|
|
|
assert.true( widget.isSelected() );
|
|
|
|
assert.true( widget.checkbox.isSelected() );
|
|
|
|
assert.false( widget.checkbox.isDisabled() );
|
2021-08-25 09:29:23 +00:00
|
|
|
assert.strictEqual( widget.checkbox.getTitle(), null );
|
2021-09-11 12:16:49 +00:00
|
|
|
|
|
|
|
widget.setSelected( false );
|
2021-11-02 01:27:09 +00:00
|
|
|
assert.false( widget.isSelected(), 'can unselect item' );
|
|
|
|
assert.false( widget.checkbox.isSelected(), 'can unselect checkbox' );
|
2021-08-25 08:31:34 +00:00
|
|
|
} );
|