Skip to main content
Module

x/rambda/sort.spec.js

Faster and smaller alternative to Ramda
Go to Latest
File
import { sort } from './sort'
const fn = (a, b) => a > b ? 1 : -1
test('sort', () => { expect(sort((a, b) => a - b)([ 2, 3, 1 ])).toEqual([ 1, 2, 3 ])})
test('it doesn\'t mutate', () => { const list = [ 'foo', 'bar', 'baz' ]
expect(sort(fn, list)).toEqual([ 'bar', 'baz', 'foo' ])
expect(list[ 0 ]).toBe('foo') expect(list[ 1 ]).toBe('bar') expect(list[ 2 ]).toBe('baz')})