mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-12 14:35:28 +00:00
54f4b47794
Bug: T311116 Change-Id: Ie4e1f9f203055f68add6fea0cf04b03215a32942
52 lines
2.3 KiB
JavaScript
52 lines
2.3 KiB
JavaScript
QUnit.module( 've.ui.MWTwoPaneTransclusionDialogLayout', ve.test.utils.newMwEnvironment() );
|
|
|
|
const createLayout = function () {
|
|
return new ve.ui.MWTwoPaneTransclusionDialogLayout( {
|
|
continuous: true,
|
|
outlined: false
|
|
} );
|
|
};
|
|
|
|
const createTemplate = function () {
|
|
const transclusion = new ve.dm.MWTransclusionModel();
|
|
return new ve.dm.MWTemplateModel( transclusion, {} );
|
|
};
|
|
|
|
const createParameterPage = function ( name, template ) {
|
|
const parameter = new ve.dm.MWParameterModel( template, name );
|
|
return new ve.ui.MWParameterPage( parameter );
|
|
};
|
|
|
|
QUnit.test( 'can add and remove multiple pages', ( assert ) => {
|
|
const layout = createLayout(),
|
|
template = createTemplate(),
|
|
parameterPageA = createParameterPage( 'Parameter A', template ),
|
|
parameterPageB = createParameterPage( 'Parameter B', template ),
|
|
parameterPageC = createParameterPage( 'Parameter C', template );
|
|
|
|
layout.addPages( [ parameterPageA, parameterPageB, parameterPageC ] );
|
|
assert.strictEqual( layout.getPage( parameterPageA.getName() ), parameterPageA );
|
|
assert.strictEqual( layout.getPage( parameterPageB.getName() ), parameterPageB );
|
|
assert.strictEqual( layout.getPage( parameterPageC.getName() ), parameterPageC );
|
|
|
|
layout.removePages( [ parameterPageA, parameterPageB ] );
|
|
assert.strictEqual( layout.getPage( parameterPageA.getName() ), undefined );
|
|
assert.strictEqual( layout.getPage( parameterPageB.getName() ), undefined );
|
|
assert.strictEqual( layout.getPage( parameterPageC.getName() ), parameterPageC );
|
|
} );
|
|
|
|
QUnit.test( 'can add a page at a specific index', ( assert ) => {
|
|
const layout = createLayout(),
|
|
template = createTemplate(),
|
|
parameterPageA = createParameterPage( 'Parameter A', template ),
|
|
parameterPageB = createParameterPage( 'Parameter B', template ),
|
|
parameterPageC = createParameterPage( 'Parameter C', template );
|
|
|
|
layout.addPages( [ parameterPageA, parameterPageB ] );
|
|
layout.addPages( [ parameterPageC ], 1 );
|
|
|
|
assert.strictEqual( layout.stackLayout.getItemIndex( parameterPageA ), 0 );
|
|
assert.strictEqual( layout.stackLayout.getItemIndex( parameterPageC ), 1 );
|
|
assert.strictEqual( layout.stackLayout.getItemIndex( parameterPageB ), 2 );
|
|
} );
|