mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-22 11:02:58 +00:00
f8cdcfe129
* The extra brackets are not needed in ES6. * Make sure the name of the test is on the next line. This makes the code easier to read. Change-Id: Ib871dbfa27fcadc88e7335b9efb4d583bd4300ac
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
QUnit.module( 've.ui.MWParameterCheckboxInputWidget' );
|
|
|
|
QUnit.test( 'Constructor passes config to parent', ( assert ) => {
|
|
const widget = new ve.ui.MWParameterCheckboxInputWidget( { selected: true } );
|
|
|
|
assert.strictEqual( widget.getValue(), '1' );
|
|
assert.strictEqual( widget.isSelected(), true );
|
|
} );
|
|
|
|
[
|
|
[ '1', true, '"1"' ],
|
|
[ '0', false, '"0"' ],
|
|
[ '', false, 'empty string' ],
|
|
[ '2', false, 'unexpected string' ],
|
|
[ true, false, 'unexpected type' ]
|
|
].forEach( ( [ value, expected, message ] ) =>
|
|
QUnit.test( `setValue( ${message} )`, ( assert ) => {
|
|
const widget = new ve.ui.MWParameterCheckboxInputWidget();
|
|
widget.setValue( value );
|
|
|
|
assert.strictEqual( widget.isSelected(), expected );
|
|
assert.strictEqual( widget.getValue(), expected ? '1' : '0' );
|
|
} )
|
|
);
|
|
|
|
[
|
|
true,
|
|
false
|
|
].forEach( ( value ) =>
|
|
QUnit.test( `setSelected( ${value} )`, ( assert ) => {
|
|
const widget = new ve.ui.MWParameterCheckboxInputWidget();
|
|
widget.setSelected( value );
|
|
|
|
assert.strictEqual( widget.isSelected(), value );
|
|
assert.strictEqual( widget.getValue(), value ? '1' : '0' );
|
|
} )
|
|
);
|