mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-15 19:50:04 +00:00
0bee0906d4
eslint \ --cache \ --max-warnings 0 \ --report-unused-disable-directives \ --fix \ src tests Change-Id: I051275126ae7fa9affd16c2504017c0584f2d9c7
40 lines
809 B
JavaScript
40 lines
809 B
JavaScript
import createExperiments from '../../src/experiments';
|
|
|
|
QUnit.module( 'ext.popups/experiments#weightedBoolean' );
|
|
|
|
QUnit.test( 'it should call mw.experiments#getBucket', function ( assert ) {
|
|
let getBucketStub = this.sandbox.stub(),
|
|
stubMWExperiments = {
|
|
getBucket: getBucketStub
|
|
},
|
|
experiments = createExperiments( stubMWExperiments );
|
|
|
|
experiments.weightedBoolean( 'foo', 0.2, 'barbaz' );
|
|
|
|
assert.ok( getBucketStub.calledOnce );
|
|
assert.deepEqual(
|
|
getBucketStub.getCall( 0 ).args,
|
|
[
|
|
{
|
|
enabled: true,
|
|
|
|
name: 'foo',
|
|
buckets: {
|
|
'true': 0.2,
|
|
'false': 0.8 // 1 - 0.2
|
|
}
|
|
},
|
|
'barbaz'
|
|
]
|
|
);
|
|
|
|
// ---
|
|
|
|
getBucketStub.returns( 'true' );
|
|
|
|
assert.ok(
|
|
experiments.weightedBoolean( 'foo', 0.2, 'barbaz' ),
|
|
'It should return true if the bucket is "true".'
|
|
);
|
|
} );
|