Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

test(errorHandlingConfig): add test for errorHandlingConfig() to be i… #15770

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions test/AngularSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,38 @@ Float32Array, Float64Array, */

describe('angular', function() {
var element, document;
var originalObjectMaxDepthInErrorMessage = minErrConfig.objectMaxDepth;

beforeEach(function() {
document = window.document;
});

afterEach(function() {
dealoc(element);
minErrConfig.objectMaxDepth = originalObjectMaxDepthInErrorMessage;
});

describe('errorHandlingConfig', function() {
it('should get default objectMaxDepth', function() {
expect(errorHandlingConfig().objectMaxDepth).toBe(5);
});

it('should set objectMaxDepth', function() {
errorHandlingConfig({objectMaxDepth: 3});
expect(errorHandlingConfig().objectMaxDepth).toBe(3);
});

it('should not change objectMaxDepth when undefined is supplied', function() {
errorHandlingConfig({objectMaxDepth: undefined});
expect(errorHandlingConfig().objectMaxDepth).toBe(originalObjectMaxDepthInErrorMessage);
});

they('should set objectMaxDepth to NaN when $prop is supplied',
[NaN, null, true, false, -1, 0], function(maxDepth) {
errorHandlingConfig({objectMaxDepth: maxDepth});
expect(errorHandlingConfig().objectMaxDepth).toBeNaN();
}
);
});

describe('case', function() {
Expand Down
9 changes: 2 additions & 7 deletions test/minErrSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,32 +78,27 @@ describe('minErr', function() {

var myError = testError('26', 'a when objectMaxDepth is default=5 is {0}', a);
expect(myError.message).toMatch(/a when objectMaxDepth is default=5 is {"b":{"c":{"d":{"e":{"f":"..."}}}}}/);
expect(errorHandlingConfig().objectMaxDepth).toBe(5);

errorHandlingConfig({objectMaxDepth: 1});
myError = testError('26', 'a when objectMaxDepth is set to 1 is {0}', a);
expect(myError.message).toMatch(/a when objectMaxDepth is set to 1 is {"b":"..."}/);
expect(errorHandlingConfig().objectMaxDepth).toBe(1);

errorHandlingConfig({objectMaxDepth: 2});
myError = testError('26', 'a when objectMaxDepth is set to 2 is {0}', a);
expect(myError.message).toMatch(/a when objectMaxDepth is set to 2 is {"b":{"c":"..."}}/);
expect(errorHandlingConfig().objectMaxDepth).toBe(2);

errorHandlingConfig({objectMaxDepth: undefined});
myError = testError('26', 'a when objectMaxDepth is set to undefined is {0}', a);
expect(myError.message).toMatch(/a when objectMaxDepth is set to undefined is {"b":{"c":"..."}}/);
expect(errorHandlingConfig().objectMaxDepth).toBe(2);
});

they('should handle arguments that are objects and ignore max depth when objectMaxDepth = $prop',
[NaN, null, true, false, -1, 0], function(maxDepth) {
var a = {b: {c: {d: 1}}};
var a = {b: {c: {d: {e: {f: {g: 1}}}}}};

errorHandlingConfig({objectMaxDepth: maxDepth});
var myError = testError('26', 'a is {0}', a);
expect(myError.message).toMatch(/a is {"b":{"c":{"d":1}}}/);
expect(errorHandlingConfig().objectMaxDepth).toBeNaN();
expect(myError.message).toMatch(/a is {"b":{"c":{"d":{"e":{"f":{"g":1}}}}}}/);
}
);

Expand Down