mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-23 23:24:39 +00:00
4ff08bd2fb
Bug: T289780 Change-Id: I8d80f4e02c6b59087c88d42be671fa81b4d37ba8
49 lines
1.1 KiB
JavaScript
49 lines
1.1 KiB
JavaScript
import * as stubs from './../stubs';
|
|
import { isEnabled } from '../../../src/instrumentation/statsv';
|
|
|
|
QUnit.module( 'ext.popups/instrumentation/statsv' );
|
|
|
|
QUnit.test( '#isEnabled', function ( assert ) {
|
|
const user = stubs.createStubUser(),
|
|
config = stubs.createStubMap(),
|
|
weightedBooleanStub = this.sandbox.stub(),
|
|
experiments = {
|
|
weightedBoolean: weightedBooleanStub
|
|
};
|
|
|
|
config.set( 'wgPopupsStatsvSamplingRate', 0.3141 );
|
|
|
|
isEnabled( user, config, experiments );
|
|
|
|
assert.strictEqual(
|
|
weightedBooleanStub.callCount,
|
|
1,
|
|
'The experiments object is called.'
|
|
);
|
|
assert.deepEqual(
|
|
weightedBooleanStub.getCall( 0 ).args,
|
|
[
|
|
'ext.Popups.statsv',
|
|
config.get( 'wgPopupsStatsvSamplingRate' ),
|
|
user.sessionId()
|
|
],
|
|
'The experiments object is called with the correct arguments.'
|
|
);
|
|
|
|
// ---
|
|
|
|
config.delete( 'wgPopupsStatsvSamplingRate' );
|
|
|
|
const defaultResult = isEnabled( user, config, experiments );
|
|
assert.strictEqual(
|
|
defaultResult,
|
|
false,
|
|
'The bucketing is disabled by default.'
|
|
);
|
|
assert.strictEqual(
|
|
weightedBooleanStub.callCount,
|
|
1,
|
|
'The experiments object is not called when bucketing rate is the default 0.'
|
|
);
|
|
} );
|