Created
June 22, 2018 18:51
-
-
Save matismasters/4d7c8924fb0d973de12760690882e1f0 to your computer and use it in GitHub Desktop.
Weird to see functional programming after so much OO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const maxLength = (firstString) => (secondString) => { | |
return firstString.length > secondString.length ? | |
firstString.length : | |
secondString.length | |
} | |
module.exports = { maxLength } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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