| Server IP : 159.203.156.69 / Your IP : 216.73.216.37 Web Server : nginx/1.24.0 System : Linux main-ubuntu 6.8.0-71-generic #71-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 16:52:38 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/tanviranik.com/node_modules/camelize/test/ |
Upload File : |
'use strict';
var test = require('tape');
var camelize = require('../');
var obj = {
fee_fie_foe: 'fum',
beep_boop: [
{ 'abc.xyz': 'mno' },
{ 'foo-bar': 'baz' }
]
};
test('camelize a nested object', function (t) {
t.plan(1);
var res = camelize(obj);
t.deepEqual(res, {
feeFieFoe: 'fum',
beepBoop: [
{ abcXyz: 'mno' },
{ fooBar: 'baz' }
]
});
});
test('string', function (t) {
t.plan(1);
t.equal(camelize('one_two'), 'oneTwo');
});
test('date', function (t) {
t.plan(1);
var d = new Date();
t.equal(camelize(d), d);
});
test('regex', function (t) {
t.plan(1);
var r = /1234/;
t.equal(camelize(r), r);
});
test('only camelize strings that are the root value', function (t) {
t.plan(2);
t.equal(camelize('foo-bar'), 'fooBar');
var res = camelize({ 'foo-bar': 'baz-foo' });
t.deepEqual(res, { fooBar: 'baz-foo' });
});