mediawiki-extensions-Cite/tests/qunit/ve-cite/ve.ui.MWUseExistingReferenceCommand.test.js

34 lines
900 B
JavaScript
Raw Normal View History

'use strict';
QUnit.module( 've.ui.MWUseExistingReferenceCommand (Cite)', ve.test.utils.newMwEnvironment() );
function getFragmentMock( hasRefs ) {
const docRefsMock = {
hasRefs: () => hasRefs
};
return {
getDocument: () => ( {
extCiteDocumentReferences: docRefsMock,
getOriginalDocument: () => undefined
} ),
getSelection: () => ( {
getName: () => 'linear'
} )
};
}
QUnit.test( 'Constructor', ( assert ) => {
const command = new ve.ui.MWUseExistingReferenceCommand();
assert.strictEqual( command.name, 'reference/existing' );
assert.strictEqual( command.action, 'window' );
assert.strictEqual( command.method, 'open' );
} );
QUnit.test( 'isExecutable', ( assert ) => {
const command = new ve.ui.MWUseExistingReferenceCommand();
assert.false( command.isExecutable( getFragmentMock( false ) ) );
assert.true( command.isExecutable( getFragmentMock( true ) ) );
} );