<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.3.4/jasmine.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.3.4/jasmine.js" type="text/javascript" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.3.4/jasmine-html.js" type="text/javascript" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.3.4/boot.js" type="text/javascript" charset="utf-8"></script>
<script src="script.js"></script>
<script src="specs.js"></script>
</head>
<body></body>
</html>
const add = (a, b) => a + b
const inc = (a) => a + 1
const dbl = (a) => a * 2
const compose = (f, g) => (...args) => f(g(...args))
const addDbl = compose(dbl, add)
const dblInc = compose(inc, dbl)
// const addIncDbl = compose(dbl, compose(inc, add))
const composeAll = (...fns) => fns.reduce(compose)
const addIncDbl = composeAll(dbl, inc, add)
// Specs
describe('add', () => {
it('should add two numbers', () => {
const result = add(1, 2)
expect(result).toEqual(3)
})
})
describe('inc', () => {
it('should add one to the passed number', () => {
const result = inc(1)
expect(result).toEqual(2)
})
})
describe('dbl', () => {
it('should double the passed number', () => {
const result = dbl(2)
expect(result).toEqual(4)
})
})
describe('addDbl', () => {
it('should add the numbers then double the result', () => {
const result = addDbl(2, 3)
expect(result).toEqual(10)
})
})
describe('dblInc', () => {
it('should double the number then increment the result', () => {
const result = dblInc(2)
expect(result).toEqual(5)
})
})
describe('addIncDbl', () => {
it('should add then increment then double', () => {
const result = addIncDbl(2, 3)
expect(result).toEqual(12)
})
})
/* Styles go here */