2018-07-23 03:02:39 -04:00
|
|
|
|
|
|
|
var assert = require('assert');
|
2018-08-01 18:05:19 -04:00
|
|
|
var fs = require('fs');
|
|
|
|
var path = require('path');
|
2018-07-23 03:02:39 -04:00
|
|
|
|
|
|
|
var utils = require('./utils');
|
|
|
|
var ethers = utils.getEthers(__filename);
|
|
|
|
|
|
|
|
describe("Package Version", function() {
|
|
|
|
var url = "http://registry.npmjs.org/ethers"
|
|
|
|
it("is not already published", function() {
|
2018-10-03 20:08:01 -04:00
|
|
|
this.timeout(20000);
|
2018-07-23 03:02:39 -04:00
|
|
|
return ethers.utils.fetchJson(url).then(function(data) {
|
|
|
|
assert.ok(Object.keys(data.versions).indexOf(ethers.version) === -1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-08-01 18:05:19 -04:00
|
|
|
// These test cases will fail if "npm run dist" has not been called to
|
|
|
|
// create the ./dist/ethers.js and ./dist/ethers.min.js. They will also
|
|
|
|
// fail if the dist files have been tampered with manually, since Travis
|
|
|
|
// CI will build them using the same tool versions in the package-lock.json.
|
|
|
|
describe("Dist Build:", function() {
|
|
|
|
|
|
|
|
// No need (and can't) check this in the browser
|
2018-08-27 14:04:21 +02:00
|
|
|
if (fs.readFileSync == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Node.js 6 does not seem to use the package-lock.json properly, so it does
|
|
|
|
// not correctly generate the uglified dist files.
|
|
|
|
var version = parseInt(process.version.match(/^v([0-9]+)/)[1]);
|
|
|
|
if (version < 8) {
|
|
|
|
return;
|
|
|
|
}
|
2018-08-01 18:05:19 -04:00
|
|
|
|
|
|
|
function test(filename) {
|
|
|
|
it("matches dist build - " + filename, function() {
|
|
|
|
var dist = fs.readFileSync(path.resolve(__dirname, '../dist/' + filename)).toString()
|
|
|
|
var checkDist = fs.readFileSync(path.resolve(__dirname, './dist/' + filename)).toString();
|
|
|
|
assert.equal(ethers.utils.id(checkDist), ethers.utils.id(dist), 'matches');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
test('ethers.js');
|
|
|
|
test('ethers.min.js');
|
2018-08-02 21:36:13 -04:00
|
|
|
|
|
|
|
it("does not have host specific includes", function() {
|
|
|
|
var data = fs.readFileSync(path.resolve(__dirname, '../dist/ethers.types.txt')).toString();
|
|
|
|
assert.ok(data.toLowerCase().indexOf('/ricmoo') === -1, 'contains ricmoo in a path');
|
|
|
|
});
|
2018-08-01 18:05:19 -04:00
|
|
|
});
|
|
|
|
|
2018-07-23 03:02:39 -04:00
|
|
|
/*
|
|
|
|
describe("Test package path resolution:", function() {
|
|
|
|
var Tests = {
|
|
|
|
"..": [
|
|
|
|
"Wallet"
|
|
|
|
],
|
|
|
|
"../contracts": [
|
|
|
|
],
|
|
|
|
"../contracts/contract": [
|
|
|
|
],
|
|
|
|
"../contracts/interface": [
|
|
|
|
],
|
|
|
|
"../providers": [
|
|
|
|
],
|
|
|
|
"../providers/InfuraProvider": [
|
|
|
|
],
|
|
|
|
"../providers/JsonRpcProvider": [
|
|
|
|
],
|
|
|
|
"../providers/FallbackProvider": [
|
|
|
|
],
|
|
|
|
"../providers/IpcProvider": [
|
|
|
|
],
|
|
|
|
"../providers/Provider": [
|
|
|
|
],
|
|
|
|
"../wallet": [
|
|
|
|
],
|
|
|
|
};
|
|
|
|
for (var key in Tests) {
|
|
|
|
it(key, function() {
|
|
|
|
var test = require(key);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
*/
|