summaryrefslogtreecommitdiff
path: root/formatter/features/steps/formatter.js
blob: f793833acacb4030d5d0b280e5f5eb573b34b237 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { Given, When, Then } from '@cucumber/cucumber'
import assert from '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)
})