2021-08-24 09:31:14 +00:00
|
|
|
QUnit.module( 've.ui.MWTransclusionOutlinePartWidget' );
|
|
|
|
|
|
|
|
QUnit.test( 'Constructor', ( assert ) => {
|
|
|
|
const transclusion = new ve.dm.MWTransclusionModel(),
|
|
|
|
part = new ve.dm.MWTransclusionPartModel( transclusion ),
|
2022-05-04 10:00:47 +00:00
|
|
|
widget = new ve.ui.MWTransclusionOutlinePartWidget( part, {
|
|
|
|
label: 'Example',
|
|
|
|
ariaDescriptionUnselected: 'Help when unselected',
|
|
|
|
ariaDescriptionSelected: 'Help when selected',
|
|
|
|
ariaDescriptionSelectedSingle: 'Help when selected and single'
|
|
|
|
} ),
|
|
|
|
$ariaElement = widget.$element.find( '[aria-describedby]' );
|
2021-08-24 09:31:14 +00:00
|
|
|
|
2021-08-24 11:17:16 +00:00
|
|
|
assert.strictEqual( widget.getData(), 'part_0' );
|
|
|
|
assert.strictEqual(
|
2022-05-04 10:00:47 +00:00
|
|
|
widget.$element.find( '.ve-ui-mwTransclusionOutlineButtonWidget .oo-ui-buttonElement-button' ).text(),
|
2021-08-24 11:17:16 +00:00
|
|
|
'Example'
|
|
|
|
);
|
2022-05-04 10:00:47 +00:00
|
|
|
assert.strictEqual( widget.isSelected(), false );
|
|
|
|
let $ariaDescription = widget.$element.find( '#' + $ariaElement.attr( 'aria-describedby' ) );
|
|
|
|
assert.strictEqual( $ariaDescription.text(), 'Help when unselected' );
|
|
|
|
|
|
|
|
widget.setSelected( true );
|
|
|
|
|
|
|
|
assert.strictEqual( widget.isSelected(), true );
|
|
|
|
$ariaDescription = widget.$element.find( '#' + $ariaElement.attr( 'aria-describedby' ) );
|
|
|
|
assert.strictEqual( $ariaDescription.text(), 'Help when selected' );
|
2021-08-24 09:31:14 +00:00
|
|
|
} );
|