{"size": 729, "ext": "js", "max_stars_repo_path": "node_modules/newrelic/test/unit/util/json-stringify-safer.test.js", "max_stars_repo_name": "jovinbm/harvardCoop", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "node_modules/newrelic/test/unit/util/json-stringify-safer.test.js", "max_issues_repo_name": "jovinbm/harvardCoop", "max_issues_repo_issues_event_min_datetime": "2015-03-12T23:52:46.000Z", "max_issues_repo_issues_event_max_datetime": "2015-04-05T13:36:57.000Z", "max_forks_repo_path": "node_modules/newrelic/test/unit/util/json-stringify-safer.test.js", "max_forks_repo_name": "jovinbm/harvardCoop", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 14, "max_forks_count": null, "avg_line_length": 22.78125, "max_line_length": 69, "alphanum_fraction": 0.5871056241}
var stringify = require('../../../lib/util/json-stringify-safer.js')
var chai = require('chai')
var expect = chai.expect


describe('stringifier', function() {
  it('should stringify objects', function() {
    var obj = {a: 1, b: 2}
    expect(stringify(obj)).equal('{"a":1,"b":2}')
  })

  it('should fail gracefully on unstringifiable objects', function(){
    var badObj = {
      get testData () {
        throw new Exception()
      }
    }
    expect(stringify(badObj)).equal('[UNPARSABLE OBJECT]')
  })

  it('should call the supplied function on failure', function(done){
    var badObj = {
      get testData () {
        throw new Exception()
      }
    }
    stringify(badObj, function(){
      done()
    })
  })
})
