Last active
March 21, 2018 00:25
-
-
Save agawish/05d52de09d8f192d234ed9b434be608f to your computer and use it in GitHub Desktop.
Survey-Dapp "Create Survey" test cases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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