Files
angular.js/test/stringifySpec.js
Peter Bacon Darwin cf43ccdf9b fix(minErr): stringify non-JSON compatible objects in error messages
Fix the JSON stringification to output a more meaningful string when an
object cannot be normally converted to a JSON string, such as when the
object contains cyclic references that would cause `JSON.stringify()`
to throw an error.

Closes #10085
2014-11-17 13:37:52 +00:00

16 lines
614 B
JavaScript

'use strict';
describe('toDebugString', function() {
it('should convert its argument to a string', function() {
expect(toDebugString('string')).toEqual('string');
expect(toDebugString(123)).toEqual('123');
expect(toDebugString({a:{b:'c'}})).toEqual('{"a":{"b":"c"}}');
expect(toDebugString(function fn() { var a = 10; })).toEqual('function fn()');
expect(toDebugString()).toEqual('undefined');
var a = { };
a.a = a;
expect(toDebugString(a)).toEqual('{"a":"<<already seen>>"}');
expect(toDebugString([a,a])).toEqual('[{"a":"<<already seen>>"},"<<already seen>>"]');
});
});