tests work in browser and node

This commit is contained in:
Manuel Araoz 2014-02-04 15:26:58 -03:00
parent 12d7274588
commit 5a90473d12
8 changed files with 40 additions and 14 deletions

View File

@ -31,10 +31,7 @@
"after",
"afterEach",
"requirejs",
"it",
"chai",
"bitcore"
"it"
],
"indent": false, // Specify indentation spacing
"devel": true, // Allow development statements e.g. `console.log();`.

View File

@ -11,7 +11,7 @@ module.exports = function(grunt) {
grunt.initConfig({
browserify: {
client: {
src: ['main.js'],
src: ['bitcore.js'],
dest: 'browser/bundle.js',
options: {
alias: ['browserify-bignum/bignumber.js:bignum'],

15
bitcore.js Normal file
View File

@ -0,0 +1,15 @@
/*
* Bitcore bindings for the browser
*/
module.exports.bignum = require('bignum');
module.exports.base58 = require('base58-native');
//module.exports.Address = require('./Address');
if (typeof process.versions === 'undefined') {
module.exports.bignum.config({EXPONENTIAL_AT: 9999999, DECIMAL_PLACES: 0, ROUNDING_MODE: 1});
}

View File

@ -1,9 +0,0 @@
/*
* Bitcore bindings for the browser
*/
module.exports.bignum = require('bignum');
module.exports.base58 = require('base58-native');
module.exports.bignum.config({EXPONENTIAL_AT: 9999999, DECIMAL_PLACES: 0, ROUNDING_MODE: 1});

17
test/adapter.js Normal file
View File

@ -0,0 +1,17 @@
'use strict';
if (typeof require === 'undefined') {
var that = this;
that.require = function(name) {
var split = name.split('/');
if (split.length > 0) {
name = split.pop();
}
var module = that[name];
if (!module) {
throw new Error('Cannot find module "'+name+'"');
}
return module;
};
}

View File

@ -8,6 +8,7 @@
</head>
<body>
<div id="mocha"></div>
<script src="adapter.js"></script>
<script src="mocha.js"></script>
<script src="../node_modules/chai/chai.js"></script>
<script>mocha.setup('bdd')</script>

View File

@ -1,5 +1,8 @@
'use strict';
var chai = require('chai');
var bitcore = require('../bitcore');
var expect = chai.expect;
var should = chai.should();

View File

@ -1,5 +1,7 @@
'use strict';
var chai = require('chai');
var bitcore = require('../bitcore');
var expect = chai.expect;
var should = chai.should();