deno.land / x / rambda@v9.1.1 / source / hasIn.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
import { hasIn as hasInRamda } from 'ramda'
import { hasIn } from './hasIn.js'
const fred = { age : 23, name : 'Fred',}const anon = { age : 99 }
test('returns a function that checks the appropriate property', () => { const nm = hasIn('name') expect(typeof nm).toBe('function') expect(nm(fred)).toBe(true) expect(nm(anon)).toBe(false)})
test('checks properties from the prototype chain', () => { function Person(){} Person.prototype.age = function (){}
const bob = new Person() expect(hasIn('age', bob)).toBe(true)})
test('works properly when called with two arguments', () => { expect(hasIn('name', fred)).toBe(true) expect(hasIn('name', anon)).toBe(false)})
test('returns false when non-existent object', () => { expect(hasIn('name', null)).toBe(false) expect(hasIn('name', undefined)).toBe(false)})
rambda

Version Info

Tagged at
2 months ago