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

@ -50,46 +50,52 @@ config({
}
});
describe("Token", function () {
describe("Token", function() {
this.timeout(0);
it("not deploy Token", function () {
assert.strictEqual(Token.address, undefined);
describe('Token Contract', function() {
it("not deploy Token", function() {
assert.strictEqual(Token.address, undefined);
});
});
it("should deploy MyToken and MyToken2", function () {
assert.ok(MyToken.options.address);
assert.ok(MyToken2.options.address);
describe('MyToken Contracts', function() {
it("should deploy MyToken and MyToken2", function() {
assert.ok(MyToken.options.address);
assert.ok(MyToken2.options.address);
});
it("set MyToken Balance correctly", async function() {
let result = await MyToken.methods._supply().call();
assert.strictEqual(parseInt(result, 10), 1000);
});
it("set MyToken2 Balance correctly", async function() {
let result = await MyToken2.methods._supply().call();
assert.strictEqual(parseInt(result, 10), 2000);
});
});
it("set MyToken Balance correctly", async function () {
let result = await MyToken.methods._supply().call();
assert.strictEqual(parseInt(result, 10), 1000);
});
describe('Other Contarcts', function() {
it("get right address", function() {
assert.strictEqual(AlreadyDeployedToken.options.address.toLowerCase(),
"0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE".toLowerCase());
});
it("set MyToken2 Balance correctly", async function () {
let result = await MyToken2.methods._supply().call();
assert.strictEqual(parseInt(result, 10), 2000);
});
it("should use onDeploy", async function() {
let result = await Test.methods.addr().call();
assert.strictEqual(result, MyToken.options.address);
});
it("get right address", function () {
assert.strictEqual(AlreadyDeployedToken.options.address.toLowerCase(),
"0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE".toLowerCase());
});
it("should not deploy if deployIf returns false", function() {
assert.ok(!SomeContract.options.address);
});
it("should use onDeploy", async function () {
let result = await Test.methods.addr().call();
assert.strictEqual(result, MyToken.options.address);
});
it("should not deploy if deployIf returns false", function() {
assert.ok(!SomeContract.options.address);
});
it("should set the ens attr to the address of embark.eth", async function() {
let result = await Test.methods.ens().call();
// Testing that it is an address as we don't really know the address
assert.strictEqual(web3.utils.isAddress(result), true);
assert.notStrictEqual(result, '0x0000000000000000000000000000000000000000');
it("should set the ens attr to the address of embark.eth", async function() {
let result = await Test.methods.ens().call();
// Testing that it is an address as we don't really know the address
assert.strictEqual(web3.utils.isAddress(result), true);
assert.notStrictEqual(result, '0x0000000000000000000000000000000000000000');
});
});
});

View File

@ -235,9 +235,20 @@ class TestRunner {
if (global.embark.needConfig) {
global.config({});
}
global.embark.onReady((_err, accounts) => {
function runDescribe(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()`
}
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);
});
}