mirror of https://github.com/embarklabs/embark.git
fix unit tests and add test_appp test for http contracts
This commit is contained in:
parent
b931efcf7d
commit
5925124978
|
@ -1,12 +1,12 @@
|
||||||
var utils = require('../utils/utils.js');
|
const utils = require('../utils/utils.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
run: function(filepath) {
|
run: function(filepath) {
|
||||||
var Mocha = require('mocha'),
|
const Mocha = require('mocha'),
|
||||||
fs = require('fs'),
|
fs = require('fs-extra'),
|
||||||
path = require('path');
|
path = require('path');
|
||||||
|
|
||||||
var mocha = new Mocha();
|
const mocha = new Mocha();
|
||||||
|
|
||||||
if (filepath) {
|
if (filepath) {
|
||||||
if (filepath.substr(-1) === '/') {
|
if (filepath.substr(-1) === '/') {
|
||||||
|
@ -60,11 +60,14 @@ module.exports = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Run the tests.
|
// Run the tests.
|
||||||
let runner = mocha.run(function(failures){
|
let runner = mocha.run(function(failures) {
|
||||||
process.on('exit', function () {
|
// Clean contracts folder for next test run
|
||||||
process.exit(failures); // exit with non-zero status if there were failures
|
fs.remove('.embark/contracts', (_err) => {
|
||||||
|
process.on('exit', function () {
|
||||||
|
process.exit(failures); // exit with non-zero status if there were failures
|
||||||
|
});
|
||||||
|
process.exit();
|
||||||
});
|
});
|
||||||
process.exit();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
runner.on('suite', function() {
|
runner.on('suite', function() {
|
||||||
|
|
|
@ -3,7 +3,6 @@ const Config = require('../lib/core/config.js');
|
||||||
const Plugins = require('../lib/core/plugins.js');
|
const Plugins = require('../lib/core/plugins.js');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const TestLogger = require('../lib/tests/test_logger.js');
|
const TestLogger = require('../lib/tests/test_logger.js');
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
describe('embark.Config', function () {
|
describe('embark.Config', function () {
|
||||||
let config = new Config({
|
let config = new Config({
|
||||||
|
@ -129,17 +128,6 @@ describe('embark.Config', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#loadContractOnTheWeb', function () {
|
|
||||||
it('should download the file correctly', async function () {
|
|
||||||
const filePath = await config.loadContractOnTheWeb(
|
|
||||||
'test_apps/test_app/.embark/contracts',
|
|
||||||
{file: 'https://github.com/embark-framework/embark/blob/master/test_app/app/contracts/simple_storage.sol'}
|
|
||||||
);
|
|
||||||
assert.strictEqual(filePath,
|
|
||||||
path.normalize('C:/dev/embark/test_apps/test_app/.embark/contracts/simple_storage.sol'));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#loadExternalContractsFiles', function () {
|
describe('#loadExternalContractsFiles', function () {
|
||||||
it('should create the right list of files and download', function () {
|
it('should create the right list of files and download', function () {
|
||||||
config.contractsFiles = [];
|
config.contractsFiles = [];
|
||||||
|
@ -153,14 +141,14 @@ describe('embark.Config', function () {
|
||||||
];
|
];
|
||||||
const expected = [
|
const expected = [
|
||||||
{
|
{
|
||||||
"filename": path.normalize("C:/dev/embark/.embark/contracts/simple_storage.sol"),
|
"filename": ".embark/contracts/simple_storage.sol",
|
||||||
"type": "http",
|
"type": "http",
|
||||||
"path": "https://raw.githubusercontent.com/embark-framework/embark/master/test_app/app/contracts/simple_storage.sol",
|
"path": "https://raw.githubusercontent.com/embark-framework/embark/master/test_app/app/contracts/simple_storage.sol",
|
||||||
"basedir": "",
|
"basedir": "",
|
||||||
"resolver": undefined
|
"resolver": undefined
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": path.normalize("C:/dev/embark/.embark/contracts/ERC725.sol"),
|
"filename": ".embark/contracts/ERC725.sol",
|
||||||
"type": "http",
|
"type": "http",
|
||||||
"path": "https://raw.githubusercontent.com/status-im/contracts/master/contracts/identity/ERC725.sol",
|
"path": "https://raw.githubusercontent.com/status-im/contracts/master/contracts/identity/ERC725.sol",
|
||||||
"basedir": "",
|
"basedir": "",
|
||||||
|
|
|
@ -71,6 +71,9 @@
|
||||||
"args": [
|
"args": [
|
||||||
1000
|
1000
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"ERC725": {
|
||||||
|
"file": "https://github.com/status-im/contracts/blob/master/contracts/identity/ERC725.sol"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"afterDeploy": [
|
"afterDeploy": [
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
/*globals describe, it*/
|
||||||
|
const fs = require('fs-extra');
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
describe('http contracts', () => {
|
||||||
|
describe('ERC725', () => {
|
||||||
|
const contractPath = '.embark/contracts/ERC725.sol';
|
||||||
|
|
||||||
|
it('should have downloaded the file in .embark/contracts', (done) => {
|
||||||
|
fs.access(contractPath, (err) => {
|
||||||
|
if (err) {
|
||||||
|
assert.fail(contractPath + ' was not downloaded');
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,3 +1,4 @@
|
||||||
|
/*global describe, it, before*/
|
||||||
|
|
||||||
describe("Token", function() {
|
describe("Token", function() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue