forked from angus-c/just
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (26 loc) · 755 Bytes
/
Copy pathindex.js
File metadata and controls
28 lines (26 loc) · 755 Bytes
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
var test = require('../util/test')(__filename);
var filter = require('../../packages/object-filter');
var compare = require('../../packages/collection-compare');
test('filter by key', function(t) {
t.plan(1);
var obj1 = {a1: 3, b1: 5, a2: 9};
var result = filter(obj1, function(key, value) {
return key[0] == 'a';
});
t.ok(compare(result, {a1: 3, a2: 9}));
t.end();
});
test('filter by value', function(t) {
t.plan(2);
var obj = {a: 3, b: 5, c: 9};
var result = filter(obj, function(key, value) {
return value < 6;
});
t.ok(compare(result, {a: 3, b: 5}));
var obj2 = {a: 3, b: 5, c: null};
var result2 = filter(obj2, function(key, value) {
return value;
});
t.ok(compare(result2, {a: 3, b: 5}));
t.end();
});