Browse Source

tests work in browser and node

patch-2
Manuel Araoz 11 years ago
parent
commit
5a90473d12
  1. 5
      .jshintrc
  2. 2
      Gruntfile.js
  3. 15
      bitcore.js
  4. 9
      main.js
  5. 17
      test/adapter.js
  6. 1
      test/index.html
  7. 3
      test/test.base58.js
  8. 2
      test/test.main.js

5
.jshintrc

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

2
Gruntfile.js

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

15
bitcore.js

@ -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});
}

9
main.js

@ -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

@ -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;
};
}

1
test/index.html

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

3
test/test.base58.js

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

2
test/test.main.js

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

Loading…
Cancel
Save