mediawiki-extensions-Popups/tests/node-qunit/statsvInstrumentation.test.js
joakin 698a93f5bc Hygiene: QUnit setup -> beforeEach & teardown -> afterEach
The setup and teardown hooks on QUnit.module are deprecated on the
latest versions.

See https://api.qunitjs.com/QUnit/module

mw-node-qunit supports them but we shouldn't be using them.

Bug: T160406
Change-Id: I32c07f22d01d16449a6e37f46ff20c577a1f14c6
2017-04-26 12:34:12 +02:00

28 lines
710 B
JavaScript

var stubs = require( './stubs' ),
statsv = require( '../../src/statsvInstrumentation' );
QUnit.module( 'ext.popups/statsvInstrumentation', {
beforeEach: function () {
this.user = stubs.createStubUser();
this.config = stubs.createStubMap();
}
} );
QUnit.test( 'isEnabled', function ( assert ) {
var experiments = stubs.createStubExperiments( true );
assert.expect( 2 );
assert.ok(
statsv.isEnabled( this.user, this.config, experiments ),
'Logging is enabled when the user is in the sample.'
);
experiments = stubs.createStubExperiments( false );
assert.notOk(
statsv.isEnabled( this.user, this.config, experiments ),
'Logging is disabled when the user is not in the sample.'
);
} );