mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-18 09:40:49 +00:00
dcb513eb0e
The ext.cite.referencePreviews module will transparently replace the ext.popups.referencePreviews module after this patch. Configuration stays in Popups for now, we can migrate it in later work. CSS classes may be renamed in the future but this will be handled separately since it could be a breaking change for on-wiki customizations. A lot of fancy footwork happens in this patch to emulate a soft dependency on Popups. This mechanism doesn't exist explicitly in either ResourceLoader or QUnit, so lots of workarounds are used, to conditionally load the module and to dynamically skip dependent tests. renderer.test.js is fully skipped for now, but can be wired up in later work. Bug: T355194 Change-Id: I0dc47abb59a40d4e41e7dda0eb7b415a2e1ae508
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
( mw.loader.getModuleNames().indexOf( 'ext.popups.main' ) !== -1 ?
|
|
QUnit.module :
|
|
QUnit.module.skip )( 'ext.cite.referencePreviews#setUserConfigFlags' );
|
|
|
|
QUnit.test( 'reference preview config settings are successfully set from bitmask', ( assert ) => {
|
|
const config = new Map();
|
|
|
|
config.set( 'wgPopupsFlags', '7' );
|
|
require( 'ext.cite.referencePreviews' ).private.setUserConfigFlags( config );
|
|
|
|
assert.deepEqual(
|
|
[
|
|
config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ),
|
|
config.get( 'wgPopupsReferencePreviews' )
|
|
],
|
|
[ true, true ]
|
|
);
|
|
|
|
config.set( 'wgPopupsFlags', '2' );
|
|
require( 'ext.cite.referencePreviews' ).private.setUserConfigFlags( config );
|
|
|
|
assert.deepEqual(
|
|
[
|
|
config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ),
|
|
config.get( 'wgPopupsReferencePreviews' )
|
|
],
|
|
[ true, false ]
|
|
);
|
|
|
|
config.set( 'wgPopupsFlags', '5' );
|
|
require( 'ext.cite.referencePreviews' ).private.setUserConfigFlags( config );
|
|
|
|
assert.deepEqual(
|
|
[
|
|
config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ),
|
|
config.get( 'wgPopupsReferencePreviews' )
|
|
],
|
|
[ false, true ]
|
|
);
|
|
|
|
config.set( 'wgPopupsFlags', '0' );
|
|
require( 'ext.cite.referencePreviews' ).private.setUserConfigFlags( config );
|
|
|
|
assert.deepEqual(
|
|
[
|
|
config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ),
|
|
config.get( 'wgPopupsReferencePreviews' )
|
|
],
|
|
[ false, false ]
|
|
);
|
|
} );
|