| 1 |
QUnit.module( 've.ui.MWTransclusionOutlinePartWidget' ); |
| 2 |
|
| 3 |
QUnit.test( 'Constructor', ( assert ) => { |
| 4 |
const transclusion = new ve.dm.MWTransclusionModel(), |
| 5 |
part = new ve.dm.MWTransclusionPartModel( transclusion ), |
| 6 |
widget = new ve.ui.MWTransclusionOutlinePartWidget( part, { |
| 7 |
label: 'Example', |
| 8 |
ariaDescriptionUnselected: 'Help when unselected', |
| 9 |
ariaDescriptionSelected: 'Help when selected', |
| 10 |
ariaDescriptionSelectedSingle: 'Help when selected and single' |
| 11 |
} ), |
| 12 |
$ariaElement = widget.$element.find( '[aria-describedby]' ); |
| 13 |
|
| 14 |
assert.strictEqual( widget.getData(), 'part_0' ); |
| 15 |
assert.strictEqual( |
| 16 |
widget.$element.find( '.ve-ui-mwTransclusionOutlineButtonWidget .oo-ui-buttonElement-button' ).text(), |
| 17 |
'Example' |
| 18 |
); |
| 19 |
assert.strictEqual( widget.isSelected(), false ); |
| 20 |
let $ariaDescription = widget.$element.find( '#' + $ariaElement.attr( 'aria-describedby' ) ); |
| 21 |
assert.strictEqual( $ariaDescription.text(), 'Help when unselected' ); |
| 22 |
|
| 23 |
widget.setSelected( true ); |
| 24 |
|
| 25 |
assert.strictEqual( widget.isSelected(), true ); |
| 26 |
$ariaDescription = widget.$element.find( '#' + $ariaElement.attr( 'aria-describedby' ) ); |
| 27 |
assert.strictEqual( $ariaDescription.text(), 'Help when selected' ); |
| 28 |
} ); |