fix(@embark/test-runner): fix describe in describe tests

This commit is contained in:
Jonathan Rainville 2019-07-17 12:32:53 -04:00 committed by Michael Bradley
parent 59eb69c412
commit c2094dbc49
2 changed files with 50 additions and 33 deletions

View File

@ -53,10 +53,13 @@ config({
describe("Token", function() { describe("Token", function() {
this.timeout(0); this.timeout(0);
describe('Token Contract', function() {
it("not deploy Token", function() { it("not deploy Token", function() {
assert.strictEqual(Token.address, undefined); assert.strictEqual(Token.address, undefined);
}); });
});
describe('MyToken Contracts', function() {
it("should deploy MyToken and MyToken2", function() { it("should deploy MyToken and MyToken2", function() {
assert.ok(MyToken.options.address); assert.ok(MyToken.options.address);
assert.ok(MyToken2.options.address); assert.ok(MyToken2.options.address);
@ -71,7 +74,9 @@ describe("Token", function () {
let result = await MyToken2.methods._supply().call(); let result = await MyToken2.methods._supply().call();
assert.strictEqual(parseInt(result, 10), 2000); assert.strictEqual(parseInt(result, 10), 2000);
}); });
});
describe('Other Contarcts', function() {
it("get right address", function() { it("get right address", function() {
assert.strictEqual(AlreadyDeployedToken.options.address.toLowerCase(), assert.strictEqual(AlreadyDeployedToken.options.address.toLowerCase(),
"0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE".toLowerCase()); "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE".toLowerCase());
@ -93,3 +98,4 @@ describe("Token", function () {
assert.notStrictEqual(result, '0x0000000000000000000000000000000000000000'); assert.notStrictEqual(result, '0x0000000000000000000000000000000000000000');
}); });
}); });
});

View File

@ -235,9 +235,20 @@ class TestRunner {
if (global.embark.needConfig) { if (global.embark.needConfig) {
global.config({}); global.config({});
} }
global.embark.onReady((_err, accounts) => {
function runDescribe(accounts) {
self.ogMochaDescribe(describeName, callback.bind(mocha, accounts)); self.ogMochaDescribe(describeName, callback.bind(mocha, accounts));
setImmediate(() => {
global.run(); // Call `run` in setImmediate to make sure tests with no `config()` don't hang
});
global.run(); // This tells mocha that it can run the test (used in conjunction with `delay()` global.run(); // This tells mocha that it can run the test (used in conjunction with `delay()`
}
if (global.embark.ready) {
// Call describe straightaway otherwise `describe` inside `describe` end with 0 Passing
return runDescribe(global.embark.accounts);
}
global.embark.onReady((_err, accounts) => {
runDescribe(accounts);
}); });
} }