|
2 | 2 |
|
3 | 3 | describe('errors', function() {
|
4 | 4 | var originalObjectMaxDepthInErrorMessage = minErrConfig.objectMaxDepth;
|
5 |
| - |
| 5 | + var originalIsUrlParameters = minErrConfig.isUrlParameters; |
6 | 6 | afterEach(function() {
|
7 | 7 | minErrConfig.objectMaxDepth = originalObjectMaxDepthInErrorMessage;
|
| 8 | + minErrConfig.isUrlParameters = originalIsUrlParameters; |
8 | 9 | });
|
9 | 10 |
|
10 | 11 | describe('errorHandlingConfig', function() {
|
11 |
| - it('should get default objectMaxDepth', function() { |
12 |
| - expect(errorHandlingConfig().objectMaxDepth).toBe(5); |
| 12 | + describe('objectMaxDepth',function() { |
| 13 | + it('should get default objectMaxDepth', function() { |
| 14 | + expect(errorHandlingConfig().objectMaxDepth).toBe(5); |
| 15 | + }); |
| 16 | + |
| 17 | + it('should set objectMaxDepth', function() { |
| 18 | + errorHandlingConfig({objectMaxDepth: 3}); |
| 19 | + expect(errorHandlingConfig().objectMaxDepth).toBe(3); |
| 20 | + }); |
| 21 | + |
| 22 | + it('should not change objectMaxDepth when undefined is supplied', function() { |
| 23 | + errorHandlingConfig({objectMaxDepth: undefined}); |
| 24 | + expect(errorHandlingConfig().objectMaxDepth).toBe(originalObjectMaxDepthInErrorMessage); |
| 25 | + }); |
| 26 | + |
| 27 | + they('should set objectMaxDepth to NaN when $prop is supplied', |
| 28 | + [NaN, null, true, false, -1, 0], function(maxDepth) { |
| 29 | + errorHandlingConfig({objectMaxDepth: maxDepth}); |
| 30 | + expect(errorHandlingConfig().objectMaxDepth).toBeNaN(); |
| 31 | + } |
| 32 | + ); |
13 | 33 | });
|
14 | 34 |
|
15 |
| - it('should set objectMaxDepth', function() { |
16 |
| - errorHandlingConfig({objectMaxDepth: 3}); |
17 |
| - expect(errorHandlingConfig().objectMaxDepth).toBe(3); |
18 |
| - }); |
19 | 35 |
|
20 |
| - it('should not change objectMaxDepth when undefined is supplied', function() { |
21 |
| - errorHandlingConfig({objectMaxDepth: undefined}); |
22 |
| - expect(errorHandlingConfig().objectMaxDepth).toBe(originalObjectMaxDepthInErrorMessage); |
| 36 | + describe('isUrlParameters',function() { |
| 37 | + it('should get default isUrlParameters', function() { |
| 38 | + expect(errorHandlingConfig().isUrlParameters).toBe(true); |
| 39 | + }); |
| 40 | + it('should set isUrlParameters', function() { |
| 41 | + errorHandlingConfig({isUrlParameters:false}); |
| 42 | + expect(errorHandlingConfig().isUrlParameters).toBe(false); |
| 43 | + errorHandlingConfig({isUrlParameters:true}); |
| 44 | + expect(errorHandlingConfig().isUrlParameters).toBe(true); |
| 45 | + }); |
| 46 | + it('should not change its value when non-boolean is supplied', function() { |
| 47 | + errorHandlingConfig({isUrlParameters:123}); |
| 48 | + expect(errorHandlingConfig().isUrlParameters).toBe(originalIsUrlParameters); |
| 49 | + }); |
23 | 50 | });
|
24 | 51 |
|
25 |
| - they('should set objectMaxDepth to NaN when $prop is supplied', |
26 |
| - [NaN, null, true, false, -1, 0], function(maxDepth) { |
27 |
| - errorHandlingConfig({objectMaxDepth: maxDepth}); |
28 |
| - expect(errorHandlingConfig().objectMaxDepth).toBeNaN(); |
29 |
| - } |
30 |
| - ); |
31 | 52 | });
|
32 | 53 |
|
33 | 54 | describe('minErr', function() {
|
@@ -164,5 +185,13 @@ describe('errors', function() {
|
164 | 185 | expect(testError('acode', 'aproblem', 'a', 'b', 'value with space').message)
|
165 | 186 | .toMatch(/^[\s\S]*\?p0=a&p1=b&p2=value%20with%20space$/);
|
166 | 187 | });
|
| 188 | + |
| 189 | + it('should not generate URL query parameters when isUrlParameters is false', function() { |
| 190 | + |
| 191 | + errorHandlingConfig({isUrlParameters:false}); |
| 192 | + expect(testError('acode', 'aproblem', 'a', 'b', 'c').message) |
| 193 | + .not.toContain('?p0=a&p1=b&p2=c'); |
| 194 | + }); |
| 195 | + |
167 | 196 | });
|
168 | 197 | });
|
0 commit comments