mediawiki-extensions-Cite/tests/qunit/ve-cite/ve.ui.MWUseExistingReferenceCommand.test.js
thiemowmde b02028b671 Move ve-cite QUnit tests to top-level tests/ directory
It's just hard to find and confusing when hidden in that
sub-directory.

Bug: T358851
Change-Id: I19ffe73b79fa9add52af12f477afe7abbc6db836
2024-04-03 12:03:33 +02:00

33 lines
1,008 B
JavaScript

'use strict';
QUnit.module( 've.ui.MWUseExistingReferenceCommand (Cite)', ve.test.utils.newMwEnvironment() );
QUnit.test( 'Constructor', function ( 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', function ( assert ) {
const command = new ve.ui.MWUseExistingReferenceCommand();
// 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.
const groups = {};
const fragment = {
getDocument: () => ( {
getInternalList: () => ( {
getNodeGroups: () => groups
} )
} ),
getSelection: () => ( {
getName: () => 'linear'
} )
};
assert.false( command.isExecutable( fragment ) );
groups[ 'mwReference/' ] = { indexOrder: [ 0 ] };
assert.true( command.isExecutable( fragment ) );
} );