deno.land / x / rambda@v9.1.1 / source / map.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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { map as mapRamda } from 'ramda'
import { map } from './map.js'
const double = x => x * 2
describe('with array', () => { it('happy', () => { expect(map(double, [ 1, 2, 3 ])).toEqual([ 2, 4, 6 ]) })
it('curried', () => { expect(map(double)([ 1, 2, 3 ])).toEqual([ 2, 4, 6 ]) })})
describe('with object', () => { const obj = { a : 1, b : 2, }
it('happy', () => { expect(map(double, obj)).toEqual({ a : 2, b : 4, }) })
it('property as second and input object as third argument', () => { const obj = { a : 1, b : 2, } const iterator = ( val, prop, inputObject ) => { expect(prop).toBeString() expect(inputObject).toEqual(obj)
return val * 2 }
expect(map(iterator)(obj)).toEqual({ a : 2, b : 4, }) })})
test('bad inputs difference between Ramda and Rambda', () => { expect(() => map(double, null)).toThrowErrorMatchingInlineSnapshot('"Incorrect iterable input"') expect(() => map(double)(undefined)).toThrowErrorMatchingInlineSnapshot('"Incorrect iterable input"') expect(() => mapRamda(double, null)).toThrowErrorMatchingInlineSnapshot('"Cannot read properties of null (reading \'fantasy-land/map\')"') expect(() => mapRamda(double, undefined)).toThrowErrorMatchingInlineSnapshot('"Cannot read properties of undefined (reading \'fantasy-land/map\')"')})
rambda

Version Info

Tagged at
2 months ago