Skip to content

Instantly share code, notes, and snippets.

@matismasters
Created June 22, 2018 18:51
Show Gist options
  • Save matismasters/4d7c8924fb0d973de12760690882e1f0 to your computer and use it in GitHub Desktop.
Save matismasters/4d7c8924fb0d973de12760690882e1f0 to your computer and use it in GitHub Desktop.
Weird to see functional programming after so much OO
const maxLength = (firstString) => (secondString) => {
return firstString.length > secondString.length ?
firstString.length :
secondString.length
}
module.exports = { maxLength }
const sanitizer = require('../src/sanitizer')
describe('#maxLength', () => {
test('should return 2 for "b" and "bc"', () => {
let maxLengthBetweenBAnd = sanitizer.maxLength('b')
expect(maxLengthBetweenBAnd('bc')).toEqual(2)
})
test('should return 2 for "b" and "bc"', () => {
let maxLengthBetweenBcAnd = sanitizer.maxLength('bc')
expect(maxLengthBetweenBcAnd('b')).toEqual(2)
})
test('should return 0 for "" and ""', () => {
let maxLengthBetweenNullAnd = sanitizer.maxLength('')
expect(maxLengthBetweenNullAnd('')).toEqual(0)
})
test('should return 5 for "abcde" and "abcde"', () => {
let maxLengthBetweenAbcdAnd = sanitizer.maxLength('abcde')
expect(maxLengthBetweenAbcdAnd('abcde')).toEqual(5)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment