mediawiki-extensions-Popups/tests/node-qunit/instrumentation/statsv.test.js
Sam Smith dcf8532cdf Hygiene: Group instrumentation modules
Following on from I4f653bba, since the schema and statsvInstrumentation
modules are similar, let's group/rename them:

  schema -> instrumentation/eventLogging
  statsvInstrumentation -> instrumentation/statsv

Change-Id: Ic59e0da7d4917f6733fd090f15d3c269af863f05
2017-06-20 11:41:37 +01:00

40 lines
925 B
JavaScript

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