2017-03-07 00:27:38 +00:00
|
|
|
var stubs = require( './stubs' ),
|
|
|
|
statsv = require( '../../src/statsvInstrumentation' );
|
|
|
|
|
2017-06-14 10:32:29 +00:00
|
|
|
QUnit.module( 'ext.popups/statsvInstrumentation' );
|
|
|
|
|
|
|
|
QUnit.test( '#isEnabled', function ( assert ) {
|
|
|
|
var user = stubs.createStubUser(),
|
|
|
|
config = stubs.createStubMap(),
|
|
|
|
weightedBooleanStub = this.sandbox.stub(),
|
|
|
|
experiments = {
|
|
|
|
weightedBoolean: weightedBooleanStub
|
|
|
|
};
|
2017-03-07 00:27:38 +00:00
|
|
|
|
2017-06-14 10:32:29 +00:00
|
|
|
config.set( 'wgPopupsStatsvSamplingRate', 0.3141 );
|
2017-03-07 00:27:38 +00:00
|
|
|
|
2017-06-14 10:32:29 +00:00
|
|
|
statsv.isEnabled( user, config, experiments );
|
2017-03-07 00:27:38 +00:00
|
|
|
|
2017-06-14 10:32:29 +00:00
|
|
|
assert.ok( weightedBooleanStub.calledOnce );
|
|
|
|
assert.deepEqual(
|
|
|
|
weightedBooleanStub.getCall( 0 ).args,
|
|
|
|
[
|
|
|
|
'ext.Popups.statsv',
|
|
|
|
config.get( 'wgPopupsStatsvSamplingRate' ),
|
|
|
|
user.sessionId()
|
|
|
|
]
|
2017-03-07 00:27:38 +00:00
|
|
|
);
|
|
|
|
|
2017-06-14 10:32:29 +00:00
|
|
|
// ---
|
|
|
|
|
|
|
|
config.delete( 'wgPopupsStatsvSamplingRate' );
|
|
|
|
|
|
|
|
statsv.isEnabled( user, config, experiments );
|
2017-03-07 00:27:38 +00:00
|
|
|
|
2017-06-14 10:32:29 +00:00
|
|
|
assert.deepEqual(
|
|
|
|
weightedBooleanStub.getCall( 1 ).args[ 1 ],
|
|
|
|
0,
|
|
|
|
'The bucketing rate should be 0 by default.'
|
2017-03-07 00:27:38 +00:00
|
|
|
);
|
|
|
|
} );
|