Browse Source
- Updated index.js test to run in Node.js and browsers - Simplified message and clarified case where two of the same versions would conflictpatch-2
Braydon Fuller
10 years ago
2 changed files with 18 additions and 43 deletions
@ -1,39 +1,16 @@ |
|||||
'use strict'; |
'use strict'; |
||||
|
|
||||
var expect = require('chai').expect; |
var should = require('chai').should(); |
||||
var bitcore = require('../'); |
var bitcore = require('../'); |
||||
|
|
||||
// current tests works only in node.js
|
describe('#versionGuard', function() { |
||||
var bdescribe = typeof window === 'undefined' ? describe : xdescribe |
|
||||
bdescribe('index.js', function() { |
|
||||
var bitcoreModulePath; |
|
||||
var bitcoreModule; |
|
||||
|
|
||||
before(function() { |
|
||||
bitcoreModulePath = require.resolve('../'); |
|
||||
bitcoreModule = require.cache[bitcoreModulePath]; |
|
||||
delete require.cache[bitcoreModulePath]; |
|
||||
}); |
|
||||
|
|
||||
after(function() { |
|
||||
require.cache[bitcoreModulePath] = bitcoreModule; |
|
||||
}); |
|
||||
|
|
||||
function importBitcore() { |
|
||||
require('../'); |
|
||||
} |
|
||||
|
|
||||
it('global._bitcore should be defined', function() { |
it('global._bitcore should be defined', function() { |
||||
expect(global._bitcore).to.equal(bitcore.version); |
should.equal(global._bitcore, bitcore.version); |
||||
}); |
|
||||
|
|
||||
it('throw error on importing other bitcore module', function() { |
|
||||
expect(importBitcore).to.throw(Error); |
|
||||
}); |
}); |
||||
|
|
||||
it('throw error on importing with defined window', function () { |
it('throw an error if version is already defined', function() { |
||||
global.window = 'window hack'; |
(function() { |
||||
expect(importBitcore).to.throw(Error); |
bitcore.versionGuard('version'); |
||||
delete global.window; |
}).should.throw('More than one instance of bitcore'); |
||||
}); |
}); |
||||
}); |
}); |
||||
|
Loading…
Reference in new issue