mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-23 11:32:51 +00:00
9297428eca
This focuses on some scenarios that are a) complex enough to be worth a test, b) but simple enough so I don't need to spend hours on comming up with a test setup. ;-) This patch also simplifies the ARIA related code in MWTransclusionOutlinePartWidget a bit. * Check 1 of the 3 ARIA configs only. Only having one is already helpful and should not be skipped. * No need for the large conditional. setAriaDescribedBy() works fine with undefined. Bug: T291157 Change-Id: I142782ec9b96147de64497f4f6a373eae05b9c8e
29 lines
1.2 KiB
JavaScript
29 lines
1.2 KiB
JavaScript
QUnit.module( 've.ui.MWTransclusionOutlinePartWidget' );
|
|
|
|
QUnit.test( 'Constructor', ( assert ) => {
|
|
const transclusion = new ve.dm.MWTransclusionModel(),
|
|
part = new ve.dm.MWTransclusionPartModel( transclusion ),
|
|
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]' );
|
|
|
|
assert.strictEqual( widget.getData(), 'part_0' );
|
|
assert.strictEqual(
|
|
widget.$element.find( '.ve-ui-mwTransclusionOutlineButtonWidget .oo-ui-buttonElement-button' ).text(),
|
|
'Example'
|
|
);
|
|
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' );
|
|
} );
|