mediawiki-extensions-Visual.../modules/ve-mw/tests/ui/widgets/ve.ui.MWTransclusionOutlineButtonWidget.test.js
Thiemo Kreuz 9297428eca Improve test coverage of template dialog outline
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
2022-05-04 12:01:58 +02:00

21 lines
620 B
JavaScript

QUnit.module( 've.ui.MWTransclusionOutlineButtonWidget' );
QUnit.test( 'Constructor', ( assert ) => {
const widget = new ve.ui.MWTransclusionOutlineButtonWidget( {} );
// eslint-disable-next-line no-jquery/no-class-state
assert.true( widget.$element.hasClass( 've-ui-mwTransclusionOutlineButtonWidget' ) );
} );
QUnit.test( 'onKeyDown', ( assert ) => {
const done = assert.async(),
widget = new ve.ui.MWTransclusionOutlineButtonWidget( {} ),
event = $.Event( 'keydown', { which: 32 } );
widget.on( 'keyPressed', ( key ) => {
assert.strictEqual( key, 32 );
done();
} );
widget.onKeyDown( event );
} );