-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
58 lines (44 loc) · 1.05 KB
/
test.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* jslint node: true */
'use strict';
var renameKey = require('./');
var test = require('tap').test;
test('rename-key', function( t ) {
var o = {
'name': 'GitHub',
'url': 'https://github.com',
};
var r = renameKey(o, 'url', 'web');
t.deepEqual(r, {
'name': 'GitHub',
'web': 'https://github.com',
});
t.deepEqual(o, {
'name': 'GitHub',
'web': 'https://github.com',
});
o.renameKey = renameKey;
r = o.renameKey('name', 'title');
t.deepEqual(r, {
'title': 'GitHub',
'web': 'https://github.com',
'renameKey': renameKey,
});
t.deepEqual(o, {
'title': 'GitHub',
'web': 'https://github.com',
'renameKey': renameKey,
});
var Base = function(){};
Base.prototype.renameKey = renameKey;
var Person = function( name, surname ){ this.name = name; this.surname = surname; };
Person.prototype = Object.create(Base.prototype);
var person = new Person('Sofie', 'Jensen');
person
.renameKey('name', 'firstName')
.renameKey('surname', 'lastName');
t.deepEqual(person, {
'firstName': 'Sofie',
'lastName': 'Jensen',
});
t.end();
});