If I write a function like so:
function calculate(int x) public returns (int) {
require(x > 0);
// Do other stuff
return x;
}
How would I write a JavaScript unit test in Truffle verifying that the require fails when I try to call the function with a parameter of -1?
Obviously, this is just an illustrative example. I can't seem to find any documentation online.
it("should never be zero", function () {
return ContractName.deployed().then(function(instance) {
return instance.calculate.call(0);
}).then(function (result) {
// What do I put here?
});
})