mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-23 23:24:39 +00:00
883c8c1aca
Change-Id: I055517998ed06fccdf50ec31251ea6aa9040abb5
58 lines
1.3 KiB
JavaScript
Executable file
58 lines
1.3 KiB
JavaScript
Executable file
#!/usr/bin/env node
|
|
const fs = require( 'fs' ),
|
|
mwNodeQunit = require( '@wikimedia/mw-node-qunit' ),
|
|
sinon = mwNodeQunit.sinon,
|
|
QUnitModule = QUnit.module,
|
|
svgInlineLoader = require( 'svg-inline-loader' );
|
|
|
|
require( '@babel/register' )( {
|
|
presets: [
|
|
[ '@babel/preset-env', {
|
|
targets: {
|
|
node: 6
|
|
}
|
|
} ]
|
|
]
|
|
} );
|
|
|
|
require.extensions[ '.svg' ] = ( module, filename ) => {
|
|
const svg = fs.readFileSync( filename, { encoding: 'utf8' } );
|
|
// eslint-disable-next-line no-underscore-dangle
|
|
module._compile( svgInlineLoader( svg ), filename );
|
|
};
|
|
|
|
sinon.config = {
|
|
injectIntoThis: true,
|
|
injectInto: null,
|
|
useFakeTimers: false,
|
|
useFakeServer: false,
|
|
properties: [ 'spy', 'stub', 'mock', 'sandbox' ]
|
|
};
|
|
|
|
mwNodeQunit.setUp();
|
|
|
|
// Override Qunit.module to set up a sinon sandbox automatically
|
|
QUnit.module = function ( name, localEnv ) {
|
|
localEnv = localEnv || {};
|
|
QUnitModule( name, {
|
|
beforeEach: function () {
|
|
const config = Object.assign( {}, sinon.config, {
|
|
injectInto: this
|
|
} );
|
|
this.sandbox = sinon.createSandbox( config );
|
|
|
|
if ( localEnv.beforeEach ) {
|
|
localEnv.beforeEach.call( this );
|
|
}
|
|
},
|
|
afterEach: function () {
|
|
// Interop with old teardown config on mediawiki codebases
|
|
|
|
this.sandbox.restore();
|
|
if ( localEnv.afterEach ) {
|
|
localEnv.afterEach.call( this );
|
|
}
|
|
}
|
|
} );
|
|
};
|