deno.land / x / rambda@v9.1.1 / source / uniqBy.spec.js

uniqBy.spec.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { uniqBy as uniqByRamda } from 'ramda'
import { uniqBy } from './uniqBy.js'
test('happy', () => { expect(uniqBy(Math.abs, [ -2, -1, 0, 1, 2 ])).toEqual([ -2, -1, 0 ])})
test('keeps elements from the left', () => { expect(uniqBy(Math.abs, [ -1, 2, 4, 3, 1, 3 ])).toEqual([ -1, 2, 4, 3 ])})
test('returns an empty array for an empty array', () => { expect(uniqBy(Math.abs, [])).toEqual([])})
test('uses R.uniq', () => { const list = [ { a : 1 }, { a : 2 }, { a : 1 } ] const expected = [ { a : 1 }, { a : 2 } ] expect(uniqBy(x => x, list)).toEqual(expected) expect(uniqByRamda(x => x, list)).toEqual(expected)})
rambda

Version Info

Tagged at
2 months ago