Repository navigation
Expand file tree
/
Copy pathindex.js
More file actions
64 lines (57 loc) · 1.35 KB
/
Copy pathindex.js
File metadata and controls
64 lines (57 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
818C
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
59
60
61
62
63
64
var test = require('../util/test')(__filename);
var omit = require('../../packages/object-omit');
var compare = require('../../packages/collection-compare');
// var obj = {a: 3, b: 5, c: 9};
// omit(obj, a, c); // {b: 5}
//
// var obj = {a: 3, b: 5, c: 9};
// omit(obj, ['a', 'b', 'd']); // {c: 9}
//
// var obj = {a: 3, b: 5, c: 9};
// omit(obj, ['a', 'a']); // {b: 5, c: 9}
test('omit returns new object', function(t) {
t.plan(1);
var obj = {a: 3, b: 5, c: 9};
t.ok(omit(obj, []) !== obj);
t.end();
});
test('omit using array', function(t) {
t.plan(1);
var obj = {a: 3, b: 5, c: 9};
t.ok(compare(omit(obj, ['a', 'c']), {b: 5}));
t.end();
});
test('omit using arguments', function(t) {
t.plan(1);
var obj = {a: 3, b: 5, c: 9};
t.ok(compare(omit(obj, 'a', 'c'), {b: 5}));
t.end();
});
test('omit using a non-existent key', function(t) {
t.plan(1);
var obj = {a: 3, b: 5, c: 9};
t.ok(compare(omit(obj, ['a', 'b', 'd']), {c: 9}));
t.end();
});
test('omit using a duplicate key', function(t) {
t.plan(1);
var obj = {a: 3, b: 5, c: 9};
t.ok(compare(omit(obj, ['a', 'a']), {b: 5, c: 9}));
t.end();
});
test('omit where obj has a function value', function(t) {
t.plan(1);
var fn = function() {
return true;
};
var obj = {
a: 3,
b: fn,
};
t.ok(
compare(omit(obj, 'a'), {
b: fn,
})
);
t.end();
});