mediawiki-extensions-Cite/tests/qunit/ve-cite/ve.ui.MWReferenceGroupInputWidget.test.js
Adam Wight b69614fc82 [refactor] groupInput takes narrower parameters
Simple parameters hide knowledge and ease testing.

Change-Id: I9a8549199a1de07b437caf274c8d5e842183f570
2024-08-28 05:48:44 +00:00

27 lines
898 B
JavaScript

'use strict';
QUnit.module( 've.ui.MWReferenceGroupInputWidget (Cite)', ve.test.utils.newMwEnvironment() );
QUnit.test( 'Constructor', ( assert ) => {
const widget = new ve.ui.MWReferenceGroupInputWidget( {
emptyGroupName: '—'
} );
assert.strictEqual( widget.emptyGroupName, '—' );
assert.strictEqual( widget.getMenu().getItemCount(), 0 );
} );
QUnit.test( 'populateMenu', ( assert ) => {
const widget = new ve.ui.MWReferenceGroupInputWidget( {
emptyGroupName: 'empty'
} );
widget.populateMenu( [ 'mwReference/', 'mwReference/foo' ] );
assert.strictEqual( widget.getMenu().getItemCount(), 2 );
assert.strictEqual( widget.getMenu().items[ 0 ].getData(), '' );
assert.strictEqual( widget.getMenu().items[ 0 ].getLabel(), 'empty' );
assert.strictEqual( widget.getMenu().items[ 1 ].getData(), 'foo' );
assert.strictEqual( widget.getMenu().items[ 1 ].getLabel(), 'foo' );
} );