test(errorHandlingConfig): add tests for errorHandlingConfig() (independent of minErr)
Closes #15770
This commit is contained in:
committed by
Georgios Kalpakas
parent
3dc0096dc4
commit
cc793a1364
@@ -7,6 +7,7 @@ Float32Array, Float64Array, */
|
||||
|
||||
describe('angular', function() {
|
||||
var element, document;
|
||||
var originalObjectMaxDepthInErrorMessage = minErrConfig.objectMaxDepth;
|
||||
|
||||
beforeEach(function() {
|
||||
document = window.document;
|
||||
@@ -14,6 +15,30 @@ describe('angular', function() {
|
||||
|
||||
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() {
|
||||
|
||||
+2
-7
@@ -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}}}}}}/);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user