From c623c4d16f14362cc50418e0f6e5875f785f587e Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sat, 29 Dec 2018 06:43:46 +0100 Subject: Add example with non-standard formatters --- formatter/features/steps/formatter.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 formatter/features/steps/formatter.js (limited to 'formatter/features/steps/formatter.js') 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) +}) -- cgit v1.2.3