mediawiki-extensions-Visual.../modules/ve-mw/tests/ui/widgets/ve.ui.MWTransclusionOutlinePlaceholderWidget.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

25 lines
990 B
JavaScript

QUnit.module( 've.ui.MWTransclusionOutlinePlaceholderWidget' );
QUnit.test( 'Constructor', ( assert ) => {
const transclusion = new ve.dm.MWTransclusionModel(),
placeholder = new ve.dm.MWTemplatePlaceholderModel( transclusion );
let widget = new ve.ui.MWTransclusionOutlinePlaceholderWidget( placeholder );
assert.strictEqual( widget.getData(), 'part_0' );
assert.strictEqual(
widget.$element.find( '.ve-ui-mwTransclusionOutlineButtonWidget' ).text(),
'visualeditor-dialog-transclusion-add-template',
'Outline item says "Add template" by default'
);
// Bypass the asynchronous .addPart() and the API request it does
transclusion.parts.push( placeholder );
widget = new ve.ui.MWTransclusionOutlinePlaceholderWidget( placeholder );
assert.strictEqual(
widget.$element.find( '.ve-ui-mwTransclusionOutlineButtonWidget' ).text(),
'visualeditor-dialog-transclusion-template-search',
'Outline item says "Template search" when this placeholder is the only part'
);
} );