|
6 | 6 | * found in the LICENSE file at https://angular.io/license |
7 | 7 | */ |
8 | 8 |
|
9 | | -import {patchMethod, zoneSymbol} from '../../lib/common/utils'; |
| 9 | +import {patchMethod, patchProperty, zoneSymbol} from '../../lib/common/utils'; |
10 | 10 |
|
11 | 11 | describe('utils', function() { |
12 | 12 |
|
@@ -61,6 +61,25 @@ describe('utils', function() { |
61 | 61 | expect(pMethod).toBe(Type.prototype.method); |
62 | 62 | }); |
63 | 63 |
|
| 64 | + it('should not patch property which is not configurable', () => { |
| 65 | + const TestType = function() {}; |
| 66 | + const originalDefineProperty = (Object as any)[zoneSymbol('defineProperty')]; |
| 67 | + if (originalDefineProperty) { |
| 68 | + originalDefineProperty( |
| 69 | + TestType.prototype, 'nonConfigurableProperty', |
| 70 | + {configurable: false, writable: true, value: 'test'}); |
| 71 | + } else { |
| 72 | + Object.defineProperty( |
| 73 | + TestType.prototype, 'nonConfigurableProperty', |
| 74 | + {configurable: false, writable: true, value: 'test'}); |
| 75 | + } |
| 76 | + patchProperty(TestType.prototype, 'nonConfigurableProperty'); |
| 77 | + const desc = Object.getOwnPropertyDescriptor(TestType.prototype, 'nonConfigurableProperty'); |
| 78 | + expect(desc.writable).toBeTruthy(); |
| 79 | + expect(!desc.get).toBeTruthy(); |
| 80 | + }); |
| 81 | + |
| 82 | + |
64 | 83 | it('should have a method name in the stacktrace', () => { |
65 | 84 | const fn = function someOtherName() { |
66 | 85 | throw new Error('MyError'); |
|
0 commit comments