Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6.1.0 #8

Merged
merged 2 commits into from
Oct 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
/* global QUnit */
const dom = require( './src/dom' ),
jQuery = require( './src/jQuery' ),
mw = require( './src/mw' ),
sinon = require( 'sinon' ),
oojs = require( './src/oo' ),
mustache = require( './src/mustache' );

module.exports = {
dom: require( './src/dom' ),
jQuery: require( './src/jQuery' ),
mw: require( './src/mw' ),
mustache: require( './src/mustache' ),
oojs: require( './src/oo' ),
sinon: require( 'sinon' )
dom, jQuery, mw, mustache, oojs, sinon,
setUp: function () {
const sandbox = sinon.sandbox.create();

dom.setUp( sandbox, global );
jQuery.setUp( sandbox, global );
mw.setUp( sandbox, global );
global.mediaWiki = global.mw;
global.jQuery = global.$;
return sandbox;
}
};
6 changes: 6 additions & 0 deletions mw-node-qunit.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#!/usr/bin/env node
const mwNodeQunit = require( './index.js' );

require( 'qunit/bin/qunit' );

if ( process.argv.includes( '--globals' ) ) {
mwNodeQunit.setUp();
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@wikimedia/mw-node-qunit",
"version": "6.0.0",
"version": "6.1.0",
"description": "Node CLI qunit runner with mediawiki additions",
"main": "index.js",
"scripts": {
"format": "prettier --write './**/*.js'",
"test": "./index.js 'tests/**/*.test.js' | tap-dot",
"test": "node mw-node-qunit.js 'tests/**/*.test.js' --globals | tap-dot",
"test:raw": "./index.js 'tests/**/*.test.js'"
},
"repository": "github:wikimedia/mw-node-qunit",
Expand Down
15 changes: 1 addition & 14 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,14 @@ QUnit.test("jQuery global is defined", function(assert) {
});

QUnit.module("QUnit patching", {
setup() {
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("a sinon sandbox is added to this.sandbox", function(assert) {
assert.equal(typeof this.sandbox, "object", "sandbox is created");
assert.equal(
typeof this.sandbox.spy,
"function",
"sandbox methods are present"
);
assert.equal(
typeof this.sandbox.stub,
"function",
"sandbox methods are present"
);
});

QUnit.module("A test that uses the DOM", {
beforeEach() {
Expand Down