Skip to content

Commit

Permalink
Update tests to use a setup file
Browse files Browse the repository at this point in the history
  • Loading branch information
ediblecode committed Sep 26, 2016
1 parent 954eeda commit c4394de
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .grunt-tasks/mochaTest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
test : {
src: ["test/**/*.js"],
src: ["test/**/*.spec.js"],
options: {
require: "babel-core/register"
require: ["babel-core/register", "./test/_setup.js"]
}
}
};
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"start": "grunt",
"webpack:dev": "SET \"NODE_ENV=development\" && webpack --progress --colors --display-error-details",
"webpack:dist": "SET \"NODE_ENV=production\" && webpack --config ./webpack.production.config.js",
"test": "mocha test/**/*.spec.js --require babel-core/register",
"test:coverage": "node ./node_modules/istanbul/lib/cli cover node_modules/mocha/bin/_mocha -- --compilers js:babel-register --recursive test",
"test:watch": "mocha test/**/*.spec.js --require babel-core/register --reporter min --watch",
"test": "mocha test/**/*.spec.js --require babel-core/register test/_setup.js",
"test:watch": "mocha test/**/*.spec.js --require babel-core/register test/_setup.js --reporter min --watch",
"test:coverage": "node ./node_modules/istanbul/lib/cli cover node_modules/mocha/bin/_mocha -- --compilers js:babel-register --require test/_setup.js test/**/*.spec.js",
"lint": "grunt lint",
"serve": "set PORT=54321&& node web/server",
"prepublish": "grunt prepublish"
Expand Down
11 changes: 11 additions & 0 deletions test/_setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-env node, mocha */

/**
* Setup dependencies for Mocha tests
*/

const jsdom = require("jsdom");

global.document = jsdom.jsdom("<html><head></head><body></body></html>");
global.window = document.defaultView;
global.jQuery = global.$ = require("jquery");
9 changes: 3 additions & 6 deletions test/unit/tabs.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-env node, mocha */

const should = require("should"),
jsdom = require("jsdom");
const should = require("should");

const KeyCodes = {
Enter: 13,
Expand Down Expand Up @@ -59,14 +58,12 @@ describe("Tabs", function() {
`;

before(function () {
document = global.document = jsdom.jsdom("<html><head></head><body></body></html>");
global.window = document.defaultView;
$ = global.jQuery = global.$ = require("jquery");
document = global.document;
$ = global.$;

Tabs = require("../../src/javascripts/tabs.js").default;
});


describe("jQuery integration", function() {

it("defined on jquery object", function() {
Expand Down

0 comments on commit c4394de

Please sign in to comment.