mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-11 14:24:24 +00:00
update specs
This commit is contained in:
parent
da9c705f7f
commit
d33d986f36
@ -108,15 +108,16 @@ program.command('run [env]').description('run dapp').action(function(env_) {
|
||||
}
|
||||
});
|
||||
|
||||
program.command('spec').description('run specs').action(function() {
|
||||
program.command('spec').description('run tests').action(function() {
|
||||
var embarkConfig = readYaml.sync("./embark.yml");
|
||||
|
||||
if (embarkConfig.type === "grunt") {
|
||||
run('jasmine');
|
||||
run('mocha');
|
||||
}
|
||||
else {
|
||||
console.log("command not available in meteor or manual mode yet");
|
||||
console.log("note: you can use embark tests with any framework");
|
||||
console.log("try running mocha test/");
|
||||
}
|
||||
});
|
||||
|
||||
@ -158,7 +159,7 @@ program.command('demo').description('create a working dapp with a SimpleStorage
|
||||
wrench.copyDirSyncRecursive(boilerPath, targetDir);
|
||||
wrench.copyDirSyncRecursive(demoPath + "/app", targetDir + "/app", {forceDelete: true});
|
||||
wrench.copyDirSyncRecursive(demoPath + "/config", targetDir + "/config", {forceDelete: true});
|
||||
wrench.copyDirSyncRecursive(demoPath + "/spec", targetDir + "/spec", {forceDelete: true});
|
||||
wrench.copyDirSyncRecursive(demoPath + "/test", targetDir + "/test", {forceDelete: true});
|
||||
|
||||
cd(targetDir);
|
||||
run('npm install');
|
||||
|
@ -1,9 +0,0 @@
|
||||
{
|
||||
"spec_dir": "spec",
|
||||
"spec_files": [
|
||||
"**/*[sS]pec.js"
|
||||
],
|
||||
"helpers": [
|
||||
"helpers/**/*.js"
|
||||
]
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
var EmbarkSpec = require('embark-framework').test;
|
||||
|
||||
describe("SimpleStorage", function() {
|
||||
beforeAll(function(done) {
|
||||
EmbarkSpec(done);
|
||||
//SimpleStorage = EmbarkSpec.request("SimpleStorage", [150]);
|
||||
});
|
||||
|
||||
it("should set constructor value", function(done) {
|
||||
SimpleStorage.storedData(function(err, result) {
|
||||
expect(result.toNumber()).toEqual(100);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("set storage value", function(done) {
|
||||
SimpleStorage.set(150, function() {
|
||||
SimpleStorage.get(function(err, result) {
|
||||
console.log(arguments);
|
||||
expect(result.toNumber()).toEqual(150);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
})
|
@ -1,9 +0,0 @@
|
||||
{
|
||||
"spec_dir": "spec",
|
||||
"spec_files": [
|
||||
"**/*[sS]pec.js"
|
||||
],
|
||||
"helpers": [
|
||||
"helpers/**/*.js"
|
||||
]
|
||||
}
|
26
demo/test/simple_storage_spec.js
Normal file
26
demo/test/simple_storage_spec.js
Normal file
@ -0,0 +1,26 @@
|
||||
var assert = require('assert');
|
||||
var Embark = require('embark-framework');
|
||||
var EmbarkSpec = Embark.initTests();
|
||||
|
||||
describe("SimpleStorage", function(done) {
|
||||
before(function(done) {
|
||||
EmbarkSpec.deployAll(done);
|
||||
});
|
||||
|
||||
it("should set constructor value", function(done) {
|
||||
SimpleStorage.storedData(function(err, result) {
|
||||
assert.equal(result.toNumber(), 100);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("set storage value", function(done) {
|
||||
SimpleStorage.set(150, function() {
|
||||
SimpleStorage.get(function(err, result) {
|
||||
assert.equal(result.toNumber(), 150);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
})
|
@ -31,12 +31,8 @@ Deploy = function(env, contractFiles, blockchainConfig, contractsConfig, chainMa
|
||||
};
|
||||
|
||||
Deploy.prototype.deploy_contract = function(contractObject, contractParams, cb) {
|
||||
console.log("called deploy_contract");
|
||||
var callback = function(e, contract) {
|
||||
console.log("got receipt");
|
||||
console.log(arguments);
|
||||
if(!e && contract.address !== undefined) {
|
||||
console.log("Contract mined! Address: " + contract.address);
|
||||
cb(contract.address);
|
||||
}
|
||||
else {
|
||||
@ -123,8 +119,6 @@ Deploy.prototype.deploy_a_contract = function(env, className, cb) {
|
||||
|
||||
var _this = this;
|
||||
this.deploy_contract(contractObject, contractParams, function(contractAddress) {
|
||||
console.log("response!");
|
||||
|
||||
if (web3.eth.getCode(contractAddress) === "0x") {
|
||||
console.log("=========");
|
||||
console.log("contract was deployed at " + contractAddress + " but doesn't seem to be working");
|
||||
|
@ -66,8 +66,11 @@ Embark = {
|
||||
|
||||
release: Release,
|
||||
|
||||
test: function(cb) {
|
||||
var tests = new Test(cb);
|
||||
initTests: function() {
|
||||
var files = ["app/contracts/simple_storage.sol"];
|
||||
var tests = new Test(files, 'development');
|
||||
|
||||
return tests;
|
||||
}
|
||||
}
|
||||
|
||||
|
25
lib/test.js
25
lib/test.js
@ -1,29 +1,24 @@
|
||||
var ethersim = require('ethersim');
|
||||
var web3 = require('web3');
|
||||
|
||||
Test = function(cb) {
|
||||
var Manager = ethersim.Manager;
|
||||
var Provider = ethersim.Provider;
|
||||
Test = function(contractFiles, _env) {
|
||||
this.env = _env || 'development';
|
||||
this.web3 = web3;
|
||||
this.web3.setProvider(ethersim.web3Provider());
|
||||
this.contractFiles = contractFiles;
|
||||
|
||||
var manager = new Manager();
|
||||
web3.setProvider(new Provider(manager));
|
||||
|
||||
Embark.init(web3);
|
||||
Embark.init(this.web3);
|
||||
Embark.blockchainConfig.loadConfigFile('config/blockchain.yml');
|
||||
Embark.contractsConfig.loadConfigFile('config/contracts.yml');
|
||||
|
||||
var files = ["app/contracts/simple_storage.sol"];
|
||||
Embark.contractsConfig.init(this.contractFiles, this.env);
|
||||
}
|
||||
|
||||
Embark.contractsConfig.init(files, 'development');
|
||||
|
||||
Embark.deployContracts('development', files, "/tmp/abi.js", "chains.json", false, false, function(abi) {
|
||||
console.log("return abi");
|
||||
console.log(abi);
|
||||
Test.prototype.deployAll = function(cb) {
|
||||
Embark.deployContracts('development', this.contractFiles, "/tmp/abi.js", "chains.json", false, false, function(abi) {
|
||||
eval(abi);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
||||
//Test.prototype.deploy_contract = function(className, params)
|
||||
|
||||
module.exports = Test;
|
||||
|
Loading…
x
Reference in New Issue
Block a user