Socket
Socket
Sign inDemoInstall

@wikimedia/mw-node-qunit

Package Overview
Dependencies
356
Maintainers
24
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.2.0 to 6.2.1

.eslintrc.json

1

index.js

@@ -1,2 +0,1 @@

/* global QUnit */
const dom = require( './src/dom' ),

@@ -3,0 +2,0 @@ jQuery = require( './src/jQuery' ),

@@ -6,4 +6,4 @@ #!/usr/bin/env node

if ( process.argv.includes( '--globals' ) ) {
mwNodeQunit.setUp();
if ( process.argv.indexOf( '--globals' ) !== -1 ) {
mwNodeQunit.setUp();
}
{
"name": "@wikimedia/mw-node-qunit",
"version": "6.2.0",
"version": "6.2.1",
"description": "Node CLI qunit runner with mediawiki additions",
"main": "index.js",
"scripts": {
"format": "prettier --write './**/*.js'",
"test": "node mw-node-qunit.js 'tests/**/*.test.js' --globals",
"lint": "eslint --cache --max-warnings 0 .",
"test": "npm run lint && node mw-node-qunit.js 'tests/**/*.test.js' --globals",
"test:raw": "./index.js 'tests/**/*.test.js'"

@@ -25,2 +25,3 @@ },

"dependencies": {
"eslint-config-wikimedia": "0.15.1",
"glob": "7.1.2",

@@ -27,0 +28,0 @@ "jquery": "3.6.0",

@@ -1,2 +0,2 @@

var
const
headless = typeof window !== 'object';

@@ -12,4 +12,4 @@

if ( !sandbox || headless ) {
const jsdom = require( 'jsdom' );
const window = new jsdom.JSDOM().window,
const jsdom = require( 'jsdom' ),
window = new jsdom.JSDOM().window,
document = window.document;

@@ -16,0 +16,0 @@

@@ -1,2 +0,2 @@

var headless = typeof window !== 'object';
const headless = typeof window !== 'object';

@@ -21,5 +21,5 @@ module.exports = {

// prevent jQuery from caching the global window object.
delete require.cache[require.resolve( 'jquery' )];
delete require.cache[ require.resolve( 'jquery' ) ];
}
}
};

@@ -1,2 +0,5 @@

var
const
MwUri = function () {
this.query = {};
},
/* eslint-disable camelcase */

@@ -17,6 +20,2 @@ namespaceIDs = {

const MwUri = function () {
this.query = {};
};
MwUri.prototype.toString = function () {

@@ -27,3 +26,3 @@ return `https://host?${Object.keys( this.query ).join( '=' )}`;

module.exports = function newMockMediaWiki() {
var config = { wgNamespaceIds: namespaceIDs };
const config = { wgNamespaceIds: namespaceIDs };
return {

@@ -41,3 +40,3 @@ Api: Api,

get: function ( name, fallback ) {
return config[name] || fallback;
return config[ name ] || fallback;
}

@@ -44,0 +43,0 @@ },

@@ -1,2 +0,2 @@

var headless = typeof window !== 'object';
const headless = typeof window !== 'object';

@@ -3,0 +3,0 @@ module.exports = {

@@ -1,2 +0,2 @@

var
const
headless = typeof window !== 'object',

@@ -3,0 +3,0 @@ newMockMediaWiki = require( './mockMediaWiki' );

@@ -1,2 +0,2 @@

var headless = typeof window !== 'object';
const headless = typeof window !== 'object';

@@ -10,3 +10,3 @@ module.exports = {

setUp: function ( sandbox, global ) {
var OO;
let OO;
if ( !sandbox || headless ) {

@@ -13,0 +13,0 @@ OO = require( 'oojs' );

@@ -1,5 +0,5 @@

QUnit.module("Deeply nested test");
QUnit.module( 'Deeply nested test' );
QUnit.test("Glob should parse and this test be run", assert => {
assert.ok("Run");
});
QUnit.test( 'Glob should parse and this test be run', ( assert ) => {
assert.ok( 'Run' );
} );

@@ -1,42 +0,43 @@

QUnit.module("Globals");
QUnit.module( 'Globals' );
QUnit.test("mediaWiki global is defined", function(assert) {
assert.equal(typeof mediaWiki, "object");
});
QUnit.test("QUnit global is defined", function(assert) {
assert.equal(typeof QUnit, "object");
});
QUnit.test("window global is defined", function(assert) {
assert.equal(typeof window, "object");
});
QUnit.test("document global is defined", function(assert) {
assert.equal(typeof document, "object");
});
QUnit.test("jQuery global is defined", function(assert) {
assert.equal(typeof jQuery, "function");
});
QUnit.test( 'mediaWiki global is defined', function ( assert ) {
assert.strictEqual( typeof mediaWiki, 'object' );
} );
QUnit.test( 'QUnit global is defined', function ( assert ) {
assert.strictEqual( typeof QUnit, 'object' );
} );
QUnit.test( 'window global is defined', function ( assert ) {
assert.strictEqual( typeof window, 'object' );
} );
QUnit.test( 'document global is defined', function ( assert ) {
assert.strictEqual( typeof document, 'object' );
} );
QUnit.test( 'jQuery global is defined', function ( assert ) {
assert.strictEqual( typeof jQuery, 'function' );
} );
QUnit.module("QUnit patching", {
beforeEach() {
this.setup = true;
}
});
QUnit.module( 'QUnit patching', {
beforeEach() {
this.setup = true;
}
} );
QUnit.test("setup and teardown methods are patched to work", function(assert) {
assert.equal(this.setup, true, "setup hook was run");
});
QUnit.test( 'setup and teardown methods are patched to work', function ( assert ) {
assert.strictEqual( this.setup, true, 'setup hook was run' );
} );
QUnit.module("A test that uses the DOM", {
beforeEach() {
this.el = $('<div id="test"/>')
.text("banana")
.append(window.document.body);
},
afterEach() {
this.el.remove();
}
});
QUnit.module( 'A test that uses the DOM', {
beforeEach() {
this.$el = $( '<div>' )
.attr( 'id', 'test' )
.text( 'banana' )
.append( window.document.body );
},
afterEach() {
this.$el.remove();
}
} );
QUnit.test("setting an element on the DOM works", function(assert) {
assert.equal(this.el.text(), "banana", "text was set on the dom properly");
});
QUnit.test( 'setting an element on the DOM works', function ( assert ) {
assert.strictEqual( this.$el.text(), 'banana', 'text was set on the dom properly' );
} );

@@ -1,11 +0,11 @@

var a = 500;
var mw = mediaWiki;
const a = 500,
mw = mediaWiki;
mw.testNamespace = {
add(x, y) {
return x + y;
},
getA() {
return a;
}
add( x, y ) {
return x + y;
},
getA() {
return a;
}
};

@@ -1,12 +0,12 @@

QUnit.module("Require script that uses globals", {
beforeEach() {
require("./script");
},
afterEach() {
delete mediaWiki.testNamespace;
}
});
QUnit.module( 'Require script that uses globals', {
beforeEach() {
require( './script' );
},
afterEach() {
delete mediaWiki.testNamespace;
}
} );
QUnit.test("Can use the things created in the required script", assert => {
assert.equal(mediaWiki.testNamespace.add(1, 2), 3);
});
QUnit.test( 'Can use the things created in the required script', ( assert ) => {
assert.equal( mediaWiki.testNamespace.add( 1, 2 ), 3 );
} );

@@ -1,6 +0,8 @@

var jsdom = require("jsdom");
var sinon = require("sinon");
const jsdom = require( 'jsdom' ),
sinon = require( 'sinon' ),
// Override Qunit.module to set up a sinon sandbox automatically
QUnitModule = QUnit.module;
// When a test() indicates asynchronicity with stop(),
// allow 3 seconds to pass before killing the test(),
// When a test indicates asynchronicity with stop(),
// allow 3 seconds to pass before killing the test,
// and assuming failure.

@@ -10,53 +12,51 @@ QUnit.config.testTimeout = 3000;

sinon.config = {
injectIntoThis: true,
injectInto: null,
useFakeTimers: false,
useFakeServer: false,
properties: ["spy", "stub", "mock", "sandbox"]
injectIntoThis: true,
injectInto: null,
useFakeTimers: false,
useFakeServer: false,
properties: [ 'spy', 'stub', 'mock', 'sandbox' ]
};
// Override Qunit.module to set up a sinon sandbox automatically
var QUnitModule = QUnit.module;
QUnit.module = function(name, localEnv) {
localEnv = localEnv || {};
QUnitModule(name, {
beforeEach: function() {
var config = Object.assign({}, sinon.config, {
injectInto: this
});
sinon.sandbox.create(config);
QUnit.module = function ( name, localEnv ) {
localEnv = localEnv || {};
QUnitModule( name, {
beforeEach: function () {
const config = Object.assign( {}, sinon.config, {
injectInto: this
} );
sinon.sandbox.create( config );
// Interop with old setup config on mediawiki codebases
if (localEnv.setup) {
localEnv.setup.call(this);
}
if (localEnv.beforeEach) {
localEnv.beforeEach.call(this);
}
},
afterEach: function() {
// Interop with old teardown config on mediawiki codebases
if (localEnv.teardown) {
localEnv.teardown.call(this);
}
if (localEnv.afterEach) {
localEnv.afterEach.call(this);
}
// Interop with old setup config on mediawiki codebases
if ( localEnv.setup ) {
localEnv.setup.call( this );
}
if ( localEnv.beforeEach ) {
localEnv.beforeEach.call( this );
}
},
afterEach: function () {
// Interop with old teardown config on mediawiki codebases
if ( localEnv.teardown ) {
localEnv.teardown.call( this );
}
if ( localEnv.afterEach ) {
localEnv.afterEach.call( this );
}
this.sandbox.restore();
}
});
this.sandbox.restore();
}
} );
};
setDOMEnvironment();
global.mediaWiki = window.mediaWiki = {};
// Set up the global environment with mediaWiki, QUnit, $ and a jsdom dom
function setDOMEnvironment() {
var dom = new jsdom.JSDOM("<!doctype html><html><body></body></html>");
global.window = dom.window;
global.document = global.window.document;
// No need to pass window to the required module given it is in the global
// and will pick it up
global.jQuery = global.$ = window.jQuery = window.$ = require("jquery");
const dom = new jsdom.JSDOM( '<!doctype html><html><body></body></html>' );
global.window = dom.window;
global.document = global.window.document;
// No need to pass window to the required module given it is in the global
// and will pick it up
global.jQuery = global.$ = window.jQuery = window.$ = require( 'jquery' );
}
setDOMEnvironment();
global.mediaWiki = window.mediaWiki = {};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc