Skip to content

Commit 5925124

Browse files
committed
fix unit tests and add test_appp test for http contracts
1 parent b931efc commit 5925124

File tree

5 files changed

+35
-22
lines changed

5 files changed

+35
-22
lines changed

lib/tests/run_tests.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
var utils = require('../utils/utils.js');
1+
const utils = require('../utils/utils.js');
22

33
module.exports = {
44
run: function(filepath) {
5-
var Mocha = require('mocha'),
6-
fs = require('fs'),
5+
const Mocha = require('mocha'),
6+
fs = require('fs-extra'),
77
path = require('path');
88

9-
var mocha = new Mocha();
9+
const mocha = new Mocha();
1010

1111
if (filepath) {
1212
if (filepath.substr(-1) === '/') {
@@ -60,11 +60,14 @@ module.exports = {
6060
};
6161

6262
// Run the tests.
63-
let runner = mocha.run(function(failures){
64-
process.on('exit', function () {
65-
process.exit(failures); // exit with non-zero status if there were failures
63+
let runner = mocha.run(function(failures) {
64+
// Clean contracts folder for next test run
65+
fs.remove('.embark/contracts', (_err) => {
66+
process.on('exit', function () {
67+
process.exit(failures); // exit with non-zero status if there were failures
68+
});
69+
process.exit();
6670
});
67-
process.exit();
6871
});
6972

7073
runner.on('suite', function() {

test/config.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const Config = require('../lib/core/config.js');
33
const Plugins = require('../lib/core/plugins.js');
44
const assert = require('assert');
55
const TestLogger = require('../lib/tests/test_logger.js');
6-
const path = require('path');
76

87
describe('embark.Config', function () {
98
let config = new Config({
@@ -129,17 +128,6 @@ describe('embark.Config', function () {
129128
});
130129
});
131130

132-
describe('#loadContractOnTheWeb', function () {
133-
it('should download the file correctly', async function () {
134-
const filePath = await config.loadContractOnTheWeb(
135-
'test_apps/test_app/.embark/contracts',
136-
{file: 'https://github.com/embark-framework/embark/blob/master/test_app/app/contracts/simple_storage.sol'}
137-
);
138-
assert.strictEqual(filePath,
139-
path.normalize('C:/dev/embark/test_apps/test_app/.embark/contracts/simple_storage.sol'));
140-
});
141-
});
142-
143131
describe('#loadExternalContractsFiles', function () {
144132
it('should create the right list of files and download', function () {
145133
config.contractsFiles = [];
@@ -153,14 +141,14 @@ describe('embark.Config', function () {
153141
];
154142
const expected = [
155143
{
156-
"filename": path.normalize("C:/dev/embark/.embark/contracts/simple_storage.sol"),
144+
"filename": ".embark/contracts/simple_storage.sol",
157145
"type": "http",
158146
"path": "https://raw.githubusercontent.com/embark-framework/embark/master/test_app/app/contracts/simple_storage.sol",
159147
"basedir": "",
160148
"resolver": undefined
161149
},
162150
{
163-
"filename": path.normalize("C:/dev/embark/.embark/contracts/ERC725.sol"),
151+
"filename": ".embark/contracts/ERC725.sol",
164152
"type": "http",
165153
"path": "https://raw.githubusercontent.com/status-im/contracts/master/contracts/identity/ERC725.sol",
166154
"basedir": "",

test_apps/test_app/config/contracts.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@
7171
"args": [
7272
1000
7373
]
74+
},
75+
"ERC725": {
76+
"file": "https://github.com/status-im/contracts/blob/master/contracts/identity/ERC725.sol"
7477
}
7578
},
7679
"afterDeploy": [
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*globals describe, it*/
2+
const fs = require('fs-extra');
3+
const assert = require('assert');
4+
5+
describe('http contracts', () => {
6+
describe('ERC725', () => {
7+
const contractPath = '.embark/contracts/ERC725.sol';
8+
9+
it('should have downloaded the file in .embark/contracts', (done) => {
10+
fs.access(contractPath, (err) => {
11+
if (err) {
12+
assert.fail(contractPath + ' was not downloaded');
13+
}
14+
done();
15+
});
16+
});
17+
});
18+
});

test_apps/test_app/test/token_spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/*global describe, it, before*/
12

23
describe("Token", function() {
34

0 commit comments

Comments
 (0)