2024-12-20 15:03:16 +01:00
|
|
|
import { Before, Given, Then } from '@cucumber/cucumber'
|
2018-12-27 08:47:18 +01:00
|
|
|
import { expect } from 'chai'
|
|
|
|
|
|
|
|
function step (name) {
|
|
|
|
this.names.push(name)
|
|
|
|
}
|
|
|
|
|
|
|
|
function decorator (f, ...args) {
|
|
|
|
if (args.length > 0) {
|
|
|
|
return function () {
|
|
|
|
f.call(this, args[0])
|
2019-01-03 06:11:13 +01:00
|
|
|
}
|
2018-12-27 08:47:18 +01:00
|
|
|
} else {
|
|
|
|
return f
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Given('a person with name', decorator(step, 'John'))
|
|
|
|
Given('a person named {word}', decorator(step))
|
|
|
|
|
|
|
|
Then('the same function is called for two distinct step definitions', function () {
|
|
|
|
expect(this.names).to.have.lengthOf(2)
|
|
|
|
expect(this.names).to.include.members(['John', 'Jack'])
|
|
|
|
})
|