deno.land / x / rambda@v9.1.1 / source / compose.spec.js
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849import { compose as composeRamda } from 'ramda'
import { add } from './add.js'import { compose } from './compose.js'import { filter } from './filter.js'import { last } from './last.js'import { map } from './map.js'
test('happy', () => { const result = compose( last, map(add(10)), map(add(1)) )([ 1, 2, 3 ])
expect(result).toBe(14)})
test('can accepts initially two arguments', () => { const result = compose(map(x => x * 2), (list, limit) => filter(x => x > limit, list))([ 1, 2, 3, 4, false ], 2)
expect(result).toEqual([ 6, 8 ])})
test('when no arguments is passed', () => { expect(() => compose()).toThrowErrorMatchingInlineSnapshot('"compose requires at least one argument"')})
test('ramda spec', () => { const f = function ( a, b, c ){ return [ a, b, c ] } const g = compose(f)
expect(g( 1, 2, 3 )).toEqual([ 1, 2, 3 ])})
test('does return correct length of composed function', () => { expect(compose( map, map, map )).toHaveLength(2) expect(composeRamda( map, map, map )).toHaveLength(2)})
Version Info