diff --git a/lib/tests/run_tests.js b/lib/tests/run_tests.js index 5ac47a005..0c41d1e7e 100644 --- a/lib/tests/run_tests.js +++ b/lib/tests/run_tests.js @@ -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() { diff --git a/test/config.js b/test/config.js index 28ea70972..82c1485a2 100644 --- a/test/config.js +++ b/test/config.js @@ -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": "", diff --git a/test_apps/test_app/config/contracts.json b/test_apps/test_app/config/contracts.json index c2cd9b55b..3ae09f341 100644 --- a/test_apps/test_app/config/contracts.json +++ b/test_apps/test_app/config/contracts.json @@ -71,6 +71,9 @@ "args": [ 1000 ] + }, + "ERC725": { + "file": "https://github.com/status-im/contracts/blob/master/contracts/identity/ERC725.sol" } }, "afterDeploy": [ diff --git a/test_apps/test_app/test/http_contract_test.js b/test_apps/test_app/test/http_contract_test.js new file mode 100644 index 000000000..0c515f1d8 --- /dev/null +++ b/test_apps/test_app/test/http_contract_test.js @@ -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(); + }); + }); + }); +}); diff --git a/test_apps/test_app/test/token_spec.js b/test_apps/test_app/test/token_spec.js index f101a7898..c76728c04 100644 --- a/test_apps/test_app/test/token_spec.js +++ b/test_apps/test_app/test/token_spec.js @@ -1,3 +1,4 @@ +/*global describe, it, before*/ describe("Token", function() {