Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gjgd committed Jul 24, 2018
1 parent 4a7448f commit a196f38
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const TestTransmuteDPOS = artifacts.require('./TestTransmuteDPOS.sol');
const RoundManager = artifacts.require('./RoundManager.sol');
const SortedDoublyLL = artifacts.require('./SortedDoublyLL.sol');
const TestProviderPool = artifacts.require('./TestProviderPool.sol');
const JobManager = artifacts.require('./JobManager.sol');

module.exports = deployer => {
deployer.deploy(TST);
Expand All @@ -12,4 +13,5 @@ module.exports = deployer => {
deployer.deploy(RoundManager);
deployer.link(SortedDoublyLL, TestProviderPool);
deployer.deploy(TestProviderPool);
deployer.deploy(JobManager);
};
37 changes: 37 additions & 0 deletions test/JobManager.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const JobManager = artifacts.require('./JobManager.sol');
require('truffle-test-utils').init();

contract('JobManager', accounts => {

let jm;

describe('submitMineral', () => {

before(async () => {
jm = await JobManager.deployed();
});

it('should store the Mineral in the minerals mapping', async () => {
await jm.submitMineral('multiplication');
const mineral = await jm.minerals.call(0);
assert.equal('multiplication', mineral);
});

it('should increase the value of numberOfMinerals', async () => {
const numberOfMinerals = await jm.numberOfMinerals.call();
await jm.submitMineral('addition');
assert.deepEqual(numberOfMinerals.add(1), await jm.numberOfMinerals.call())
});

it('should emit a MineralAdded event', async () => {
let result = await jm.submitMineral('division');
assert.web3Event(result, {
event: 'MineralAdded',
args: {
id: 2,
name: 'division',
}
});
});
});
});

0 comments on commit a196f38

Please sign in to comment.