Skip to content

Instantly share code, notes, and snippets.

@agawish
Last active March 21, 2018 00:25
Show Gist options
  • Save agawish/05d52de09d8f192d234ed9b434be608f to your computer and use it in GitHub Desktop.
Save agawish/05d52de09d8f192d234ed9b434be608f to your computer and use it in GitHub Desktop.
Survey-Dapp "Create Survey" test cases
describe('Create New Survey Test Cases', () => {
// ## Example #1
it(`1. Given that I’m the Survey Maker
2. When I try to create a new Survey and included the survey creation costs and survey reward
3. Then I should be able to get the created survey reference number and address`, () => {
return surveyFactory.createSurvey.call({ value: _surveyRewardAndCreationCost, from: _surveyMaker })
.then(([surveyId, surveyAddress]) => {
return surveyId;
}).should.eventually.be.bignumber.equals(0);
});
// ## Example #2
it(`1. Given that I’m the Survey Maker
2. When I try to create a new Survey and included the survey creation costs and survey reward
3. Then I should be assigned as the owner of the newly created survey`, () => {
let newSurveyAddress;
return surveyFactory.createSurvey.call({ value: _surveyRewardAndCreationCost, from: _surveyMaker })
.then(([surveyId, surveyAddress]) => {
newSurveyAddress = surveyAddress;
return surveyFactory.createSurvey({ value: _surveyRewardAndCreationCost, from: _surveyMaker });
}).then(receipt => {
return Survey.at(newSurveyAddress);
}).then(surveyInstance => {
return surveyInstance.owner.call();
}).should.eventually.equal(_surveyMaker);
});
// ## Example #3
it(`1. Given that I’m the Survey Maker
2. When I try to create a new survey without including the survey creation cost
3. Then I should receive a "revert" Error`, () => {
return expectRevert(surveyFactory.createSurvey.call({ from: _surveyMaker }));
});
// ## Example #4
it(`1. Given that I’m the Survey App Owner
2. When I try to create a new Survey
3. Then I should receive a "revert" Error`, () => {
return expectRevert(surveyFactory.createSurvey.call({ from: _appOwner }));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment