Guest User

Untitled

a guest
Jan 16th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. var Calculator = artifacts.require("./Calculator.sol");
  2.  
  3. contract('Calculator', function (accounts) {
  4. var calculator;
  5. beforeEach(function () {
  6. return Calculator.new(10)
  7. .then(function (instance) {
  8. calculator = instance;
  9. });
  10. });
  11.  
  12. it("should put initial number", function () {
  13. return calculator.getResult.call().then(function (result) {
  14. console.log('address:',calculator.address,'current result:',result.valueOf());
  15. assert.equal(result.valueOf(), 10, 'Wrong initial number!');
  16. });
  17. });
  18.  
  19. it("should add 10", function () {
  20. return calculator.getResult.call().then(function (result) {
  21. console.log('address:',calculator.address,'current result:',result.valueOf());
  22. })
  23. .then(function () {
  24. return calculator.addToNumber(10);
  25. })
  26. .then(function () {
  27. return calculator.getResult.call();
  28. }).then(function (result) {
  29. assert.equal(result.valueOf(), 20, 'addToNumber failed');
  30. });
  31. });
  32. it("should multiply by 3", function () {
  33. console.log(calculator.address);
  34. return calculator.getResult.call().then(function (result) {
  35. console.log(result.valueOf());
  36. })
  37. .then(function () {
  38. return calculator.multiplyWithNumber(3);
  39. })
  40. .then(function () {
  41. return calculator.getResult.call();
  42. }).then(function (result) {
  43. assert.equal(result.valueOf(), 30, 'multiplyWithNumber failed');
  44. });
  45. });
  46.  
  47. });
Add Comment
Please, Sign In to add comment