tra-analysis/website/functions/node_modules/snakeize/test/snakeize.js
2019-01-06 13:14:45 -06:00

37 lines
762 B
JavaScript

var test = require('tape');
var snakeize = require('../');
var obj = {
feeFieFoe: 'fum',
beepBoop: [
{ 'abcXyz': 'mno' },
{ 'FooBar': 'baz' },
{ 'CheeseID': 'wensleydale' }
]
};
test('snakeize a nested object', function (t) {
t.plan(1);
var res = snakeize(obj);
t.deepEqual(res, {
"fee_fie_foe": "fum",
"beep_boop": [
{ "abc_xyz": "mno" },
{ "foo_bar": "baz" },
{ "cheese_id": "wensleydale" }
]
});
});
test('date object is not modified', function (t) {
t.plan(1);
var d = new Date();
t.equal(snakeize(d), d);
});
test('regex object is not modified', function (t) {
t.plan(1);
var r = /1234/;
t.equal(snakeize(r), r);
});