1 /* global describe, it, xit, expect */
3 describe('Error', function () {
6 var supportsDescriptors = Object.defineProperty && (function () {
9 Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
10 for (var _ in obj) { return false; } // jscs:ignore disallowUnusedVariables
12 } catch (e) { /* this is ES3 */
16 var ifSupportsDescriptorsIt = supportsDescriptors ? it : xit;
18 describe('#toString()', function () {
19 it('stringifies a newed error properly', function () {
21 var error = new RangeError(msg);
22 expect(error.name).toBe('RangeError');
23 expect(error.message).toBe(msg);
24 expect(String(error)).toBe(error.name + ': ' + msg);
27 it('stringifies a thrown error properly', function () {
31 throw new RangeError(msg);
35 expect(error.name).toBe('RangeError');
36 expect(error.message).toBe(msg);
37 expect(String(error)).toBe(error.name + ': ' + msg);
41 describe('enumerability of prototype properties', function () {
42 ifSupportsDescriptorsIt('#message', function () {
43 expect(Object.prototype.propertyIsEnumerable.call(Error.prototype, 'message')).toBe(false);
46 ifSupportsDescriptorsIt('#name', function () {
47 expect(Object.prototype.propertyIsEnumerable.call(Error.prototype, 'name')).toBe(false);