mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-12-18 02:00:53 +00:00
Hygiene: replace jQuery.noop dependency
Replace $.noop dependency with inline empty function. The tests relied on a single function instance to pass. A toString() comparison of the noop function cannot be used as they differ when coverage is enabled. Change-Id: I641801593beb240a8f7d06e388a0e41dc8a25bc6
This commit is contained in:
parent
531b4f33ad
commit
4ce0246d78
BIN
resources/dist/index.js
vendored
BIN
resources/dist/index.js
vendored
Binary file not shown.
BIN
resources/dist/index.js.json
vendored
BIN
resources/dist/index.js.json
vendored
Binary file not shown.
|
@ -89,7 +89,7 @@ function getPageviewTracker( config, loader, trackerGetter, sendBeacon ) {
|
|||
sendBeacon( url );
|
||||
} );
|
||||
};
|
||||
return config.get( 'wgPopupsVirtualPageViews' ) ? pageviewTracker : $.noop;
|
||||
return config.get( 'wgPopupsVirtualPageViews' ) ? pageviewTracker : () => {};
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -53,7 +53,7 @@ const mw = mediaWiki,
|
|||
*
|
||||
* If logging metrics to StatsD is enabled for the duration of the user's
|
||||
* session, then the appriopriate function is `mw.track`; otherwise it's
|
||||
* `$.noop`.
|
||||
* `() => {}`.
|
||||
*
|
||||
* [0]: https://github.com/wikimedia/mediawiki-extensions-WikimediaEvents/blob/29c864a0/modules/ext.wikimediaEvents.statsd.js
|
||||
*
|
||||
|
@ -63,7 +63,7 @@ const mw = mediaWiki,
|
|||
* @return {EventTracker}
|
||||
*/
|
||||
function getStatsvTracker( user, config, experiments ) {
|
||||
return isStatsvEnabled( user, config, experiments ) ? mw.track : $.noop;
|
||||
return isStatsvEnabled( user, config, experiments ) ? mw.track : () => {};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,7 +72,7 @@ function getStatsvTracker( user, config, experiments ) {
|
|||
*
|
||||
* If logging EventLogging events is enabled for the duration of the user's
|
||||
* session, then the appriopriate function is `mw.track`; otherwise it's
|
||||
* `$.noop`.
|
||||
* `() => {}`.
|
||||
*
|
||||
* [0]: https://github.com/wikimedia/mediawiki-extensions-EventLogging/blob/d1409759/modules/ext.eventLogging.subscriber.js
|
||||
*
|
||||
|
@ -86,7 +86,7 @@ function getEventLoggingTracker( user, config, window ) {
|
|||
user,
|
||||
config,
|
||||
window
|
||||
) ? mw.track : $.noop;
|
||||
) ? mw.track : () => {};
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
* @module previewBehaviour
|
||||
*/
|
||||
|
||||
const mw = mediaWiki,
|
||||
$ = jQuery;
|
||||
const mw = mediaWiki;
|
||||
|
||||
/**
|
||||
* A collection of event handlers specific to how the user interacts with all
|
||||
|
@ -34,7 +33,7 @@ const mw = mediaWiki,
|
|||
* @return {ext.popups.PreviewBehavior}
|
||||
*/
|
||||
export default function createPreviewBehavior( user, actions ) {
|
||||
let settingsUrl, showSettings = $.noop;
|
||||
let settingsUrl, showSettings = () => {};
|
||||
|
||||
if ( user.isAnon() ) {
|
||||
showSettings = ( event ) => {
|
||||
|
|
|
@ -42,15 +42,18 @@ QUnit.test( 'it shouldn\'t set the settingsUrl if the user is logged out', funct
|
|||
} );
|
||||
|
||||
QUnit.test( 'it shouldn\'t set a showSettings handler if the user is logged in', function ( assert ) {
|
||||
const user = createStubUser( /* isAnon = */ false ),
|
||||
actions = {},
|
||||
const
|
||||
user = createStubUser( /* isAnon = */ false ),
|
||||
event = {
|
||||
preventDefault: this.sandbox.spy()
|
||||
},
|
||||
actions = {
|
||||
showSettings: () => assert.ok( false, 'No show settings handler is set.' )
|
||||
},
|
||||
behavior = createPreviewBehavior( user, actions );
|
||||
|
||||
assert.strictEqual(
|
||||
behavior.showSettings,
|
||||
$.noop,
|
||||
'No show settings handler is set.'
|
||||
);
|
||||
behavior.showSettings( event );
|
||||
assert.ok( true );
|
||||
} );
|
||||
|
||||
QUnit.test( 'it should set a showSettings handler if the user is logged out', function ( assert ) {
|
||||
|
|
Loading…
Reference in a new issue