reuse: Apply function with Ramda and Lodash
This commit is contained in:
		
							
								
								
									
										15
									
								
								reuse/features/steps/lodash.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								reuse/features/steps/lodash.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
import { Before, Given, Then } from 'cucumber'
 | 
			
		||||
import { expect } from 'chai'
 | 
			
		||||
import _ from 'lodash'
 | 
			
		||||
 | 
			
		||||
function step (name) {
 | 
			
		||||
  this.names.push(name)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Given('a person with a first name', _.partial(step, 'John'))
 | 
			
		||||
Given('a person with the first name {word}', step)
 | 
			
		||||
 | 
			
		||||
Then('the first names are collected by the same function', function () {
 | 
			
		||||
  expect(this.names).to.have.lengthOf(2)
 | 
			
		||||
  expect(this.names).to.include.members(['John', 'Jack'])
 | 
			
		||||
})
 | 
			
		||||
							
								
								
									
										15
									
								
								reuse/features/steps/ramda.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								reuse/features/steps/ramda.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
import { Before, Given, Then } from 'cucumber'
 | 
			
		||||
import { expect } from 'chai'
 | 
			
		||||
import R from 'ramda'
 | 
			
		||||
 | 
			
		||||
function step (name) {
 | 
			
		||||
  this.names.push(name)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Given('a person with a last name', R.partial(step, ['Junior']))
 | 
			
		||||
Given('a person with the last name {word}', R.partial(step, []))
 | 
			
		||||
 | 
			
		||||
Then('the last names are collected by the same function', function () {
 | 
			
		||||
  expect(this.names).to.have.lengthOf(2)
 | 
			
		||||
  expect(this.names).to.include.members(['Junior', 'Doe'])
 | 
			
		||||
})
 | 
			
		||||
@@ -1,10 +1,6 @@
 | 
			
		||||
import { Before, Given, Then } from 'cucumber'
 | 
			
		||||
import { expect } from 'chai'
 | 
			
		||||
 | 
			
		||||
Before(function () {
 | 
			
		||||
  this.names = []
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
function step (name) {
 | 
			
		||||
  this.names.push(name)
 | 
			
		||||
}
 | 
			
		||||
@@ -13,7 +9,7 @@ function decorator (f, ...args) {
 | 
			
		||||
  if (args.length > 0) {
 | 
			
		||||
    return function () {
 | 
			
		||||
      f.call(this, args[0])
 | 
			
		||||
    } 
 | 
			
		||||
    }
 | 
			
		||||
  } else {
 | 
			
		||||
    return f
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user