mediawiki-extensions-Cite/tests/qunit/ve-cite/ve.ui.MWReferenceDialog.test.js
WMDE-Fisch b483c829ab Extract some methods around the reference insert/update workflow
Includes renaming the method so it's more clear what it's doing.

As preparation for adding the extends warning to the edit pane and
to allow easier identification of parts belonging to the edit
workflow.

Change-Id: If84c5dbdee19c0ebc0a28b50dda93fef3f558c6e
2024-07-02 12:30:11 +02:00

37 lines
1.1 KiB
JavaScript

'use strict';
QUnit.module( 've.ui.MWReferenceDialog (Cite)', ve.test.utils.newMwEnvironment() );
QUnit.test( 'setReferenceForEditing', ( assert ) => {
const dialog = new ve.ui.MWReferenceDialog();
dialog.referenceGroupInput = new ve.ui.MWReferenceGroupInputWidget( {} );
dialog.reuseWarning = new OO.ui.MessageWidget();
// XXX: This is a regression test with a fragile setup. Please feel free to delete this test
// when you feel like it doesn't make sense to update it.
dialog.referenceTarget = {
setDocument: () => null
};
dialog.fragment = {
getDocument: () => ( {
getInternalList: () => ( {
getNodeGroup: () => null
} )
} )
};
const parentDoc = {
cloneWithData: () => null
};
const ref = new ve.dm.MWReferenceModel( parentDoc );
ref.setGroup( 'g' );
dialog.setReferenceForEditing( ref );
assert.strictEqual( dialog.referenceModel, ref );
assert.strictEqual( dialog.originalGroup, 'g' );
assert.strictEqual( dialog.referenceGroupInput.getValue(), 'g' );
assert.false( dialog.referenceGroupInput.isDisabled() );
assert.false( dialog.reuseWarning.isVisible() );
} );