From 41198ff031f6a33b41f80ddda5428ff665149469 Mon Sep 17 00:00:00 2001 From: Esteban Ordano Date: Wed, 1 Oct 2014 18:02:17 -0300 Subject: [PATCH] Fix tests: Allow single files to be run --- Gruntfile.js | 4 ++-- karma.conf.js | 4 ++-- karma/setup.js => setup/karma.js | 0 setup/node.js | 16 +++++++++++++++ test/{models => }/HDParams.js | 0 test/{models => }/HDPath.js | 0 test/{models => }/Passphrase.js | 0 test/{models => }/PayPro.js | 0 test/{models => }/PrivateKey.js | 0 test/{models => }/PublicKeyRing.js | 0 test/{models => }/Storage.js | 0 test/{models => }/TxProposal.js | 0 test/{models => }/TxProposals.js | 0 test/{models => }/Wallet.js | 0 test/{models => }/WalletFactory.js | 0 test/{models => }/WalletLock.js | 0 test/{models => }/blockchain.Insight.js | 0 test/mocha.opts | 2 +- test/mocha_node_setup.js | 27 ------------------------- test/{models => }/network.Async.js | 0 test/{models => }/performance.js | 0 21 files changed, 21 insertions(+), 32 deletions(-) rename karma/setup.js => setup/karma.js (100%) create mode 100644 setup/node.js rename test/{models => }/HDParams.js (100%) rename test/{models => }/HDPath.js (100%) rename test/{models => }/Passphrase.js (100%) rename test/{models => }/PayPro.js (100%) rename test/{models => }/PrivateKey.js (100%) rename test/{models => }/PublicKeyRing.js (100%) rename test/{models => }/Storage.js (100%) rename test/{models => }/TxProposal.js (100%) rename test/{models => }/TxProposals.js (100%) rename test/{models => }/Wallet.js (100%) rename test/{models => }/WalletFactory.js (100%) rename test/{models => }/WalletLock.js (100%) rename test/{models => }/blockchain.Insight.js (100%) delete mode 100644 test/mocha_node_setup.js rename test/{models => }/network.Async.js (100%) rename test/{models => }/performance.js (100%) diff --git a/Gruntfile.js b/Gruntfile.js index 04e3537e0..f29432857 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -88,12 +88,12 @@ module.exports = function(grunt) { mochaTest: { tests: { options: { - require: 'test/mocha_node_setup.js', + require: 'setup/node.js', reporter: 'spec', mocha: require('mocha') }, src: [ - 'test/models/*.js', + 'test/*.js', ] } }, diff --git a/karma.conf.js b/karma.conf.js index d2953b68a..c4841e4f7 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -63,8 +63,8 @@ module.exports = function(config) { 'test/mocha.conf.js', //test files - 'karma/setup.js', - 'test/models/*.js', + 'setup/karma.js', + 'test/*.js', 'test/unit/**/*.js', diff --git a/karma/setup.js b/setup/karma.js similarity index 100% rename from karma/setup.js rename to setup/karma.js diff --git a/setup/node.js b/setup/node.js new file mode 100644 index 000000000..7fdf6c8eb --- /dev/null +++ b/setup/node.js @@ -0,0 +1,16 @@ +global.chai = require('chai'); +global.sinon = require('sinon'); +global.bitcore = require('bitcore'); +global.expect = global.chai.expect; +global.bignum = global.bitcore.Bignum; +global.should = global.chai.should(); + +global.copay = require('../copay'); +global.copayConfig = require('../config'); + +global.requireMock = function(name) { + return require('../test/mocks/' + name); +} + +global.is_browser = typeof process == 'undefined' || typeof process.versions === 'undefined'; +global._ = require('underscore'); diff --git a/test/models/HDParams.js b/test/HDParams.js similarity index 100% rename from test/models/HDParams.js rename to test/HDParams.js diff --git a/test/models/HDPath.js b/test/HDPath.js similarity index 100% rename from test/models/HDPath.js rename to test/HDPath.js diff --git a/test/models/Passphrase.js b/test/Passphrase.js similarity index 100% rename from test/models/Passphrase.js rename to test/Passphrase.js diff --git a/test/models/PayPro.js b/test/PayPro.js similarity index 100% rename from test/models/PayPro.js rename to test/PayPro.js diff --git a/test/models/PrivateKey.js b/test/PrivateKey.js similarity index 100% rename from test/models/PrivateKey.js rename to test/PrivateKey.js diff --git a/test/models/PublicKeyRing.js b/test/PublicKeyRing.js similarity index 100% rename from test/models/PublicKeyRing.js rename to test/PublicKeyRing.js diff --git a/test/models/Storage.js b/test/Storage.js similarity index 100% rename from test/models/Storage.js rename to test/Storage.js diff --git a/test/models/TxProposal.js b/test/TxProposal.js similarity index 100% rename from test/models/TxProposal.js rename to test/TxProposal.js diff --git a/test/models/TxProposals.js b/test/TxProposals.js similarity index 100% rename from test/models/TxProposals.js rename to test/TxProposals.js diff --git a/test/models/Wallet.js b/test/Wallet.js similarity index 100% rename from test/models/Wallet.js rename to test/Wallet.js diff --git a/test/models/WalletFactory.js b/test/WalletFactory.js similarity index 100% rename from test/models/WalletFactory.js rename to test/WalletFactory.js diff --git a/test/models/WalletLock.js b/test/WalletLock.js similarity index 100% rename from test/models/WalletLock.js rename to test/WalletLock.js diff --git a/test/models/blockchain.Insight.js b/test/blockchain.Insight.js similarity index 100% rename from test/models/blockchain.Insight.js rename to test/blockchain.Insight.js diff --git a/test/mocha.opts b/test/mocha.opts index f009d3996..cf9aa2649 100644 --- a/test/mocha.opts +++ b/test/mocha.opts @@ -1 +1 @@ ---require test/mocha_node_setup.js --reporter spec test/models/*.js +--require setup/node.js --reporter spec diff --git a/test/mocha_node_setup.js b/test/mocha_node_setup.js deleted file mode 100644 index 0bac889af..000000000 --- a/test/mocha_node_setup.js +++ /dev/null @@ -1,27 +0,0 @@ -if (!!global) { - global.chai = require('chai'); - global.sinon = require('sinon'); - global.bitcore = require('bitcore'); - global.expect = global.chai.expect; - global.bignum = global.bitcore.Bignum; - global.should = global.chai.should(); - - try { - global.copay = require('copay'); - global.copayConfig = require('config'); - } catch (e) { - global.copay = require('../copay'); - global.copayConfig = require('../config'); - } - - global.requireMock = function(name) { - try { - return require('../mocks/' + name); - } catch (e) { - return require('./mocks/' + name); - } - } - - global.is_browser = typeof process == 'undefined' || typeof process.versions === 'undefined'; - global._ = require('underscore'); -} diff --git a/test/models/network.Async.js b/test/network.Async.js similarity index 100% rename from test/models/network.Async.js rename to test/network.Async.js diff --git a/test/models/performance.js b/test/performance.js similarity index 100% rename from test/models/performance.js rename to test/performance.js