mediawiki-extensions-Cite/modules/ve-cite/tests/ve.ui.MWReferenceDialog.test.js
thiemowmde d6a58cfa8d Add initial QUnit tests relevant for reference re-use in VE
Note these are more meant as regression test to better cover what's
done in other patches. Everybody should feel free to delete a test
when it gets in the way. I marked a few especially fragile places
with respective comments.

Bug: T358652
Change-Id: I7844907fe3ef4f3439717381b4ecdac9e2d0a825
2024-03-21 09:37:26 +01:00

37 lines
1.1 KiB
JavaScript

'use strict';
QUnit.module( 've.ui.MWReferenceDialog (Cite)', ve.test.utils.newMwEnvironment() );
QUnit.test( 'useReference', function ( 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.useReference( 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() );
} );