mediawiki-extensions-Cite/tests/qunit/ve-cite/ve.ui.MWReferenceEditPanel.test.js
WMDE-Fisch 48d0699f09 Add method to get the updated ref from the edit panel
That's another step to separate the editing form the dialog. The dialog should not know about internals of the edit panel.

And eventually the dialog can get rid of the referenceModel property.

Bug: T369005
Change-Id: I9cf3a68ef58bc5791497af362c0572734e4bcadd
2024-08-12 18:00:32 +00:00

28 lines
1,013 B
JavaScript

'use strict';
QUnit.module( 've.ui.MWReferenceEditPanel (Cite)', ve.test.utils.newMwEnvironment() );
QUnit.test( 'setReferenceForEditing', ( assert ) => {
ve.init.target.surface = { commandRegistry: { registry: {} } };
const editPanel = new ve.ui.MWReferenceEditPanel();
const emptyDoc = new ve.dm.Document( [
{ type: 'paragraph', internal: { generated: 'empty' } },
{ type: '/paragraph' },
{ type: 'internalList' },
{ type: '/internalList' }
] );
const ref = new ve.dm.MWReferenceModel( emptyDoc );
editPanel.setInternalList( emptyDoc.getInternalList() );
ref.setGroup( 'g' );
editPanel.setReferenceForEditing( ref );
assert.strictEqual( editPanel.originalGroup, 'g' );
assert.strictEqual( editPanel.referenceGroupInput.getValue(), 'g' );
assert.false( editPanel.referenceGroupInput.isDisabled() );
assert.false( editPanel.reuseWarning.isVisible() );
assert.false( editPanel.extendsWarning.isVisible() );
assert.strictEqual( editPanel.getReferenceFromEditing().getGroup(), 'g' );
} );