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 = {
|
||||
run: function(filepath) {
|
||||
var Mocha = require('mocha'),
|
||||
fs = require('fs'),
|
||||
const Mocha = require('mocha'),
|
||||
fs = require('fs-extra'),
|
||||
path = require('path');
|
||||
|
||||
var mocha = new Mocha();
|
||||
const mocha = new Mocha();
|
||||
|
||||
if (filepath) {
|
||||
if (filepath.substr(-1) === '/') {
|
||||
|
@ -60,11 +60,14 @@ module.exports = {
|
|||
};
|
||||
|
||||
// Run the tests.
|
||||
let runner = mocha.run(function(failures){
|
||||
process.on('exit', function () {
|
||||
process.exit(failures); // exit with non-zero status if there were failures
|
||||
let runner = mocha.run(function(failures) {
|
||||
// Clean contracts folder for next test run
|
||||
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() {
|
||||
|
|
|
@ -3,7 +3,6 @@ const Config = require('../lib/core/config.js');
|
|||
const Plugins = require('../lib/core/plugins.js');
|
||||
const assert = require('assert');
|
||||
const TestLogger = require('../lib/tests/test_logger.js');
|
||||
const path = require('path');
|
||||
|
||||
describe('embark.Config', function () {
|
||||
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 () {
|
||||
it('should create the right list of files and download', function () {
|
||||
config.contractsFiles = [];
|
||||
|
@ -153,14 +141,14 @@ describe('embark.Config', function () {
|
|||
];
|
||||
const expected = [
|
||||
{
|
||||
"filename": path.normalize("C:/dev/embark/.embark/contracts/simple_storage.sol"),
|
||||
"filename": ".embark/contracts/simple_storage.sol",
|
||||
"type": "http",
|
||||
"path": "https://raw.githubusercontent.com/embark-framework/embark/master/test_app/app/contracts/simple_storage.sol",
|
||||
"basedir": "",
|
||||
"resolver": undefined
|
||||
},
|
||||
{
|
||||
"filename": path.normalize("C:/dev/embark/.embark/contracts/ERC725.sol"),
|
||||
"filename": ".embark/contracts/ERC725.sol",
|
||||
"type": "http",
|
||||
"path": "https://raw.githubusercontent.com/status-im/contracts/master/contracts/identity/ERC725.sol",
|
||||
"basedir": "",
|
||||
|
|
|
@ -71,6 +71,9 @@
|
|||
"args": [
|
||||
1000
|
||||
]
|
||||
},
|
||||
"ERC725": {
|
||||
"file": "https://github.com/status-im/contracts/blob/master/contracts/identity/ERC725.sol"
|
||||
}
|
||||
},
|
||||
"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() {
|
||||
|
||||
|
|
Loading…
Reference in New Issue