summaryrefslogtreecommitdiff
path: root/formatter/features
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2018-12-29 06:43:46 +0100
committerEugen Wissner <belka@caraus.de>2018-12-30 06:43:46 +0100
commitc623c4d16f14362cc50418e0f6e5875f785f587e (patch)
tree34c66a7bac3107a26b437d6965d328fc9bd260e6 /formatter/features
parentfe4f62ff1a3346476aa6f4d025324d7d6cecf952 (diff)
downloadcucumber-js-demo-c623c4d16f14362cc50418e0f6e5875f785f587e.tar.gz
Add example with non-standard formatters
Diffstat (limited to 'formatter/features')
-rw-r--r--formatter/features/formatter.feature16
-rw-r--r--formatter/features/steps/formatter.js29
2 files changed, 45 insertions, 0 deletions
diff --git a/formatter/features/formatter.feature b/formatter/features/formatter.feature
new file mode 100644
index 0000000..2c22ac0
--- /dev/null
+++ b/formatter/features/formatter.feature
@@ -0,0 +1,16 @@
+Feature:
+ Scenario:
+ Given the numbers:
+ | Summand | Summand |
+ | 1 | 1 |
+ When I sum them
+ Then I get 2
+
+ Given a list of proper names:
+ | Jakob |
+ | Ludwig |
+ | Felix |
+ | Mendelssohn |
+ | Bartholdy |
+ When I concatenate them together
+ Then the name is "Jakob Ludwig Felix Mendelssohn Bartholdy"
diff --git a/formatter/features/steps/formatter.js b/formatter/features/steps/formatter.js
new file mode 100644
index 0000000..a0dcff9
--- /dev/null
+++ b/formatter/features/steps/formatter.js
@@ -0,0 +1,29 @@
+const { Given, When, Then } = require('cucumber')
+const assert = require('assert')
+
+Given('the numbers:', function (dataTable) {
+ this.numbers = dataTable.rows()[0]
+ })
+
+When('I sum them', function () {
+ this.sum = this.numbers
+ .map(x => parseInt(x))
+ .reduce((x, acc) => acc + x, 0)
+})
+
+Then('I get {int}', function (int) {
+ assert.equal(this.sum, int)
+})
+
+Given('a list of proper names:', function (dataTable) {
+ this.names = dataTable.raw()
+ .map(x => x[0])
+})
+
+When('I concatenate them together', function () {
+ this.name = this.names.join(' ')
+})
+
+Then('the name is {string}', function (string) {
+ assert.equal(this.name, string)
+})