mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-12 06:27:01 +00:00
Merge "Consistent use of .forEach() in QUnit tests"
This commit is contained in:
commit
26b3f5abf0
|
@ -115,7 +115,7 @@
|
|||
null,
|
||||
[],
|
||||
{}
|
||||
].forEach( ( templateData ) => {
|
||||
].forEach( ( templateData ) =>
|
||||
QUnit.test( 'Invalid TemplateData, e.g. empty or without params', ( assert ) => {
|
||||
const template = createTemplateMock(),
|
||||
spec = new ve.dm.MWTemplateSpecModel( template );
|
||||
|
@ -136,8 +136,8 @@
|
|||
assert.strictEqual( spec.isParameterSuggested( 'p' ), false, 'isParameterSuggested' );
|
||||
assert.strictEqual( spec.isParameterDeprecated( 'p' ), false, 'isParameterDeprecated' );
|
||||
assert.strictEqual( spec.getParameterDeprecationDescription( 'p' ), '', 'getParameterDeprecationDescription' );
|
||||
} );
|
||||
} );
|
||||
} )
|
||||
);
|
||||
|
||||
QUnit.test( 'Basic behavior with minimal setTemplateData()', ( assert ) => {
|
||||
const template = createTemplateMock( [ 'p1' ] ),
|
||||
|
@ -283,7 +283,7 @@
|
|||
|
||||
[ { notemplatedata: false }, true, 'unexpected false' ],
|
||||
[ { notemplatedata: '' }, true, 'unsupported formatversion=1' ]
|
||||
].forEach( ( [ templateData, expected, message ] ) => {
|
||||
].forEach( ( [ templateData, expected, message ] ) =>
|
||||
QUnit.test( 'isDocumented(): ' + message, ( assert ) => {
|
||||
const template = createTemplateMock(),
|
||||
spec = new ve.dm.MWTemplateSpecModel( template );
|
||||
|
@ -292,8 +292,8 @@
|
|||
|
||||
spec.setTemplateData( templateData );
|
||||
assert.strictEqual( spec.isDocumented(), expected );
|
||||
} );
|
||||
} );
|
||||
} )
|
||||
);
|
||||
|
||||
QUnit.test( 'getDocumentedParameterOrder() should not return a reference', ( assert ) => {
|
||||
const template = createTemplateMock(),
|
||||
|
|
|
@ -43,11 +43,13 @@
|
|||
[ '/unexpected_prefix', '/unexpected prefix' ],
|
||||
[ './Template:%C3%9Cnicode%5Fexample/subpage', 'Template:Ünicode example/subpage' ],
|
||||
[ './Template:Possibly_invalid%5B%5D', 'Template:Possibly invalid[]' ]
|
||||
].forEach( ( [ href, expected ] ) => QUnit.test( 'getTitle: ' + href, ( assert ) => {
|
||||
const transclusion = { getUniquePartId: () => 0 },
|
||||
template = new ve.dm.MWTemplateModel( transclusion, { href } );
|
||||
assert.strictEqual( template.getTitle(), expected );
|
||||
} ) );
|
||||
].forEach( ( [ href, expected ] ) =>
|
||||
QUnit.test( 'getTitle: ' + href, ( assert ) => {
|
||||
const transclusion = { getUniquePartId: () => 0 },
|
||||
template = new ve.dm.MWTemplateModel( transclusion, { href } );
|
||||
assert.strictEqual( template.getTitle(), expected );
|
||||
} )
|
||||
);
|
||||
|
||||
QUnit.test( 'hasParameter', ( assert ) => {
|
||||
const template = newTemplateModel();
|
||||
|
@ -164,7 +166,7 @@
|
|||
},
|
||||
expected: [ 'foo', 'bar', 'empty' ]
|
||||
}
|
||||
].forEach( ( { name, spec, expected } ) => {
|
||||
].forEach( ( { name, spec, expected } ) =>
|
||||
QUnit.test( name, ( assert ) => {
|
||||
const template = newTemplateModel();
|
||||
|
||||
|
@ -172,8 +174,8 @@
|
|||
|
||||
const serialization = template.serialize();
|
||||
assert.deepEqual( Object.keys( serialization.template.params ), expected );
|
||||
} );
|
||||
} );
|
||||
} )
|
||||
);
|
||||
|
||||
[
|
||||
{
|
||||
|
@ -277,7 +279,7 @@
|
|||
''
|
||||
]
|
||||
}
|
||||
].forEach( ( { name, spec, expected } ) => {
|
||||
].forEach( ( { name, spec, expected } ) =>
|
||||
QUnit.test( 'getOrderedParameterNames: ' + name, ( assert ) => {
|
||||
const template = newTemplateModel();
|
||||
|
||||
|
@ -286,8 +288,8 @@
|
|||
}
|
||||
|
||||
assert.deepEqual( template.getOrderedParameterNames(), expected );
|
||||
} );
|
||||
} );
|
||||
} )
|
||||
);
|
||||
|
||||
[
|
||||
{
|
||||
|
@ -405,7 +407,7 @@
|
|||
''
|
||||
]
|
||||
}
|
||||
].forEach( ( { name, spec, expected } ) => {
|
||||
].forEach( ( { name, spec, expected } ) =>
|
||||
QUnit.test( 'getAllParametersOrdered: ' + name, ( assert ) => {
|
||||
const template = newTemplateModel();
|
||||
|
||||
|
@ -414,6 +416,7 @@
|
|||
}
|
||||
|
||||
assert.deepEqual( template.getAllParametersOrdered(), expected );
|
||||
} );
|
||||
} );
|
||||
} )
|
||||
);
|
||||
|
||||
}() );
|
||||
|
|
|
@ -13,21 +13,25 @@ QUnit.test( 'Constructor passes config to parent', ( assert ) => {
|
|||
[ '', 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 );
|
||||
].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' );
|
||||
} ) );
|
||||
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 );
|
||||
].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' );
|
||||
} ) );
|
||||
assert.strictEqual( widget.isSelected(), value );
|
||||
assert.strictEqual( widget.getValue(), value ? '1' : '0' );
|
||||
} )
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue