mediawiki-extensions-Popups/tests/node-qunit/statsvInstrumentation.test.js
Sam Smith 6159af3151 i13n: Extract experiments module
... from the statsvInstrumentation module so that the bucketing logic
can be shared with other instrumentation modules.

Change-Id: I5732fa539a3911939fa85fa88c102fa8dcfa5613
2017-06-14 11:04:32 -07:00

40 lines
917 B
JavaScript

var stubs = require( './stubs' ),
statsv = require( '../../src/statsvInstrumentation' );
QUnit.module( 'ext.popups/statsvInstrumentation' );
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.'
);
} );