Skip to main content
Module

x/rambda/sortBy.spec.js

Faster and smaller alternative to Ramda
Go to Latest
File
import { compose } from './compose'import { prop } from './prop'import { sortBy } from './sortBy'import { toLower } from './toLower'
test('happy', () => { const input = [ { a : 2 }, { a : 1 }, { a : 1 }, { a : 3 } ] const expected = [ { a : 1 }, { a : 1 }, { a : 2 }, { a : 3 } ]
const result = sortBy(x => x.a)(input) expect(result).toEqual(expected)})
test('with compose', () => { const alice = { name : 'ALICE', age : 101, } const bob = { name : 'Bob', age : -10, } const clara = { name : 'clara', age : 314.159, } const people = [ clara, bob, alice ] const sortByNameCaseInsensitive = sortBy(compose(toLower, prop('name')))
expect(sortByNameCaseInsensitive(people)).toEqual([ alice, bob, clara ])})