fix unit tests and add test_appp test for http contracts

This commit is contained in:
Jonathan Rainville 2018-04-18 14:56:18 -04:00
parent b931efcf7d
commit 5925124978
5 changed files with 35 additions and 22 deletions

View File

@ -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) === '/') {
@ -61,11 +61,14 @@ module.exports = {
// Run the tests.
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();
});
});
runner.on('suite', function() {
global.assert = require('assert');

View File

@ -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": "",

View File

@ -71,6 +71,9 @@
"args": [
1000
]
},
"ERC725": {
"file": "https://github.com/status-im/contracts/blob/master/contracts/identity/ERC725.sol"
}
},
"afterDeploy": [

View File

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

View File

@ -1,3 +1,4 @@
/*global describe, it, before*/
describe("Token", function() {