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
25 lines (22 loc) · 696 Bytes
/
Copy pathindex.js
File metadata and controls
25 lines (22 loc) · 696 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
var test = require('../util/test')(__filename);
var flip = require('../../packages/object-flip');
test('flip primitive values', function(t) {
t.plan(3);
t.deepEqual(flip({a: 'x', b: 'y', c: 'z'}), {x: 'a', y: 'b', z: 'c'});
t.deepEqual(flip({a: 1, b: 2, c: 3}), {'1': 'a', '2': 'b', '3': 'c'});
t.deepEqual(flip({a: false, b: true}), {false: 'a', true: 'b'});
t.end();
});
test('flip falsey values', function(t) {
t.plan(1);
t.deepEqual(flip({a: null, b: undefined}), {null: 'a', undefined: 'b'});
t.end();
});
test('flip complex values', function(t) {
t.plan(1);
t.deepEqual(flip({a: {x: 1}, b: [1, 2]}), {
'[object Object]': 'a',
'1,2': 'b',
});
t.end();
});