2017-07-28 17:32:46 +00:00
|
|
|
import * as stubs from './../stubs';
|
|
|
|
import { isEnabled } from '../../../src/instrumentation/statsv';
|
2017-03-07 00:27:38 +00:00
|
|
|
|
2017-06-15 12:15:46 +00:00
|
|
|
QUnit.module( 'ext.popups/instrumentation/statsv' );
|
2017-06-14 10:32:29 +00:00
|
|
|
|
|
|
|
QUnit.test( '#isEnabled', function ( assert ) {
|
2018-03-19 19:39:41 +00:00
|
|
|
const user = stubs.createStubUser(),
|
2017-06-14 10:32:29 +00:00
|
|
|
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-07-28 17:32:46 +00:00
|
|
|
isEnabled( user, config, experiments );
|
2017-03-07 00:27:38 +00:00
|
|
|
|
2018-05-08 19:48:17 +00:00
|
|
|
assert.strictEqual(
|
|
|
|
weightedBooleanStub.callCount,
|
|
|
|
1,
|
|
|
|
'The experiments object is called.'
|
|
|
|
);
|
2017-06-14 10:32:29 +00:00
|
|
|
assert.deepEqual(
|
|
|
|
weightedBooleanStub.getCall( 0 ).args,
|
|
|
|
[
|
|
|
|
'ext.Popups.statsv',
|
|
|
|
config.get( 'wgPopupsStatsvSamplingRate' ),
|
|
|
|
user.sessionId()
|
2018-05-08 19:48:17 +00:00
|
|
|
],
|
|
|
|
'The experiments object is called with the correct arguments.'
|
2017-03-07 00:27:38 +00:00
|
|
|
);
|
|
|
|
|
2017-06-14 10:32:29 +00:00
|
|
|
// ---
|
|
|
|
|
|
|
|
config.delete( 'wgPopupsStatsvSamplingRate' );
|
|
|
|
|
2017-07-28 17:32:46 +00:00
|
|
|
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
|
|
|
);
|
|
|
|
} );
|