mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-17 20:41:32 +00:00
0bee0906d4
eslint \ --cache \ --max-warnings 0 \ --report-unused-disable-directives \ --fix \ src tests Change-Id: I051275126ae7fa9affd16c2504017c0584f2d9c7
40 lines
916 B
JavaScript
40 lines
916 B
JavaScript
import * as stubs from './../stubs';
|
|
import { isEnabled } from '../../../src/instrumentation/statsv';
|
|
|
|
QUnit.module( 'ext.popups/instrumentation/statsv' );
|
|
|
|
QUnit.test( '#isEnabled', function ( assert ) {
|
|
let user = stubs.createStubUser(),
|
|
config = stubs.createStubMap(),
|
|
weightedBooleanStub = this.sandbox.stub(),
|
|
experiments = {
|
|
weightedBoolean: weightedBooleanStub
|
|
};
|
|
|
|
config.set( 'wgPopupsStatsvSamplingRate', 0.3141 );
|
|
|
|
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' );
|
|
|
|
isEnabled( user, config, experiments );
|
|
|
|
assert.deepEqual(
|
|
weightedBooleanStub.getCall( 1 ).args[ 1 ],
|
|
0,
|
|
'The bucketing rate should be 0 by default.'
|
|
);
|
|
} );
|