Datadog API Node.JS Client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

26 lines
1.1 KiB

const assert = require('assert');
const BigNumber = require('bignumber.js');
const json = require('../lib/json');
describe('json', function() {
describe('#parse()', function() {
it('should properly parse big integers', function() {
// DEV: This test case is from: https://github.com/brettlangdon/node-dogapi/issues/16
const data = '{"id": 2868860079149422351}';
const parsed = json.parse(data);
// `parsed.id` is an instance of `BigNumber`
assert.equal(parsed.id.toString(), '2868860079149422351');
});
});
describe('#stringify()', function() {
it('should properly parse big integers', function() {
// DEV: This test case is from: https://github.com/brettlangdon/node-dogapi/issues/16
const data = {id: new BigNumber('2868860079149422351')};
const stringified = json.stringify(data);
// Yeah, it ends up being a string and not an int, but mostly we
// want to make sure it doesn't throw an error or provide the wrong number
assert.equal(stringified, '{"id":"2868860079149422351"}');
});
});
});