forked from ramda/ramda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhasIn.js
33 lines (26 loc) · 874 Bytes
/
hasIn.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
var R = require('../source/index.js');
var eq = require('./shared/eq.js');
describe('hasIn', function() {
var fred = {name: 'Fred', age: 23};
var anon = {age: 99};
it('returns a function that checks the appropriate property', function() {
var nm = R.hasIn('name');
eq(typeof nm, 'function');
eq(nm(fred), true);
eq(nm(anon), false);
});
it('checks properties from the prototype chain', function() {
var Person = function() {};
Person.prototype.age = function() {};
var bob = new Person();
eq(R.hasIn('age', bob), true);
});
it('works properly when called with two arguments', function() {
eq(R.hasIn('name', fred), true);
eq(R.hasIn('name', anon), false);
});
it('returns false when non-existent object', function() {
eq(R.hasIn('name', null), false);
eq(R.hasIn('name', undefined), false);
});
});