Skip to content
This repository has been archived by the owner on Feb 25, 2019. It is now read-only.

Commit

Permalink
Add tests for setJobId
Browse files Browse the repository at this point in the history
  • Loading branch information
thodges-gh committed Aug 31, 2018
1 parent 5c4b429 commit e057628
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions test/MyContract_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ contract('MyContract', () => {
cc = await MyContract.new(link.address, oc.address, {from: consumer});
});

describe("#setJobId", () => {
context("when called by a non-owner", () => {
it("does not set", async () => {
await assertActionThrows(async () => {
await cc.setJobId(jobId, {from: stranger});
});
});
});

context("when called by the owner", () => {
it("sets the job id", async () => {
await cc.setJobId(jobId, {from: consumer});
});
});
});

describe("#requestEthereumPrice", () => {
context("without a JobID", () => {
it("reverts", async () => {
Expand All @@ -24,10 +40,12 @@ contract('MyContract', () => {
});
});
});

context("with a JobID", () => {
beforeEach(async () => {
await cc.setJobId(jobId, {from: consumer});
});

context("without LINK", () => {
it("reverts", async () => {
await assertActionThrows(async () => {
Expand Down Expand Up @@ -81,7 +99,6 @@ contract('MyContract', () => {

it("records the data given to it by the oracle", async () => {
await oc.fulfillData(internalId, response, {from: oracleNode});

let currentPrice = await cc.currentPrice.call();
assert.equal(web3.toUtf8(currentPrice), response);
});
Expand Down Expand Up @@ -151,7 +168,6 @@ contract('MyContract', () => {
});

describe("#withdrawLink", () => {

beforeEach(async () => {
await link.transfer(cc.address, web3.toWei('1', 'ether'));
});
Expand Down

0 comments on commit e057628

Please sign in to comment.