Created
June 21, 2020 16:27
-
-
Save HowardvanRooijen/a3b390ae11487c31811f573f8904a643 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // features/example/ | |
| example.jsmodule.exports = function () | |
| { | |
| this.Given(/^I have entered (.*) into the calculator$/, function (value, callback) | |
| { | |
| if (!this.valueStack) | |
| { | |
| this.valueStack = []; | |
| } | |
| this.valueStack.push(Number(value)); | |
| callback(); | |
| }); | |
| this.Given(/^I press divide$/, function (callback) | |
| { | |
| if (!this.operatorStack) | |
| { | |
| this.operatorStack = []; | |
| } | |
| this.operatorStack.push("divide"); | |
| callback(); | |
| }); | |
| this.When(/^I press equal/, function (callback) | |
| { | |
| var operator = this.operatorStack.pop(); | |
| switch (operator) | |
| { | |
| case "divide": | |
| var right = this.valueStack.pop(); | |
| var left = this.valueStack.pop(); | |
| this.result = left / right; | |
| break; | |
| } | |
| callback(); | |
| }); | |
| this.Then(/^The result should be (.*) on the screen$/, function (result, callback) | |
| { | |
| if (this.result === Number(result)) | |
| { | |
| callback(); | |
| } | |
| else | |
| { | |
| callback(new Error("Expected " + result + " actual " + this.result)); | |
| } | |
| }); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment