mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-17 20:41:32 +00:00
dcf8532cdf
Following on from I4f653bba, since the schema and statsvInstrumentation modules are similar, let's group/rename them: schema -> instrumentation/eventLogging statsvInstrumentation -> instrumentation/statsv Change-Id: Ic59e0da7d4917f6733fd090f15d3c269af863f05
40 lines
925 B
JavaScript
40 lines
925 B
JavaScript
var stubs = require( './../stubs' ),
|
|
statsv = require( '../../../src/instrumentation/statsv' );
|
|
|
|
QUnit.module( 'ext.popups/instrumentation/statsv' );
|
|
|
|
QUnit.test( '#isEnabled', function ( assert ) {
|
|
var user = stubs.createStubUser(),
|
|
config = stubs.createStubMap(),
|
|
weightedBooleanStub = this.sandbox.stub(),
|
|
experiments = {
|
|
weightedBoolean: weightedBooleanStub
|
|
};
|
|
|
|
config.set( 'wgPopupsStatsvSamplingRate', 0.3141 );
|
|
|
|
statsv.isEnabled( user, config, experiments );
|
|
|
|
assert.ok( weightedBooleanStub.calledOnce );
|
|
assert.deepEqual(
|
|
weightedBooleanStub.getCall( 0 ).args,
|
|
[
|
|
'ext.Popups.statsv',
|
|
config.get( 'wgPopupsStatsvSamplingRate' ),
|
|
user.sessionId()
|
|
]
|
|
);
|
|
|
|
// ---
|
|
|
|
config.delete( 'wgPopupsStatsvSamplingRate' );
|
|
|
|
statsv.isEnabled( user, config, experiments );
|
|
|
|
assert.deepEqual(
|
|
weightedBooleanStub.getCall( 1 ).args[ 1 ],
|
|
0,
|
|
'The bucketing rate should be 0 by default.'
|
|
);
|
|
} );
|