2024-03-11 12:35:39 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
QUnit.module( 've.ui.MWUseExistingReferenceCommand (Cite)', ve.test.utils.newMwEnvironment() );
|
|
|
|
|
2024-09-10 09:50:27 +00:00
|
|
|
function getFragmentMock( hasRefs ) {
|
2024-08-30 10:40:27 +00:00
|
|
|
const docRefsMock = {
|
|
|
|
hasRefs: () => hasRefs
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
getDocument: () => ( {
|
|
|
|
getOriginalDocument: () => undefined,
|
2024-09-10 09:50:27 +00:00
|
|
|
getStorage: () => docRefsMock,
|
|
|
|
setStorage: () => undefined
|
2024-08-30 10:40:27 +00:00
|
|
|
} ),
|
|
|
|
getSelection: () => ( {
|
|
|
|
getName: () => 'linear'
|
|
|
|
} )
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-05-31 14:27:11 +00:00
|
|
|
QUnit.test( 'Constructor', ( assert ) => {
|
2024-03-11 12:35:39 +00:00
|
|
|
const command = new ve.ui.MWUseExistingReferenceCommand();
|
|
|
|
assert.strictEqual( command.name, 'reference/existing' );
|
|
|
|
assert.strictEqual( command.action, 'window' );
|
|
|
|
assert.strictEqual( command.method, 'open' );
|
|
|
|
} );
|
|
|
|
|
2024-05-31 14:27:11 +00:00
|
|
|
QUnit.test( 'isExecutable', ( assert ) => {
|
2024-03-11 12:35:39 +00:00
|
|
|
const command = new ve.ui.MWUseExistingReferenceCommand();
|
|
|
|
|
2024-09-10 09:50:27 +00:00
|
|
|
assert.false( command.isExecutable( getFragmentMock( false ) ) );
|
|
|
|
assert.true( command.isExecutable( getFragmentMock( true ) ) );
|
2024-03-11 12:35:39 +00:00
|
|
|
} );
|