(
target: any,
shouldPatchedProperties?: string[],
ignoredProperties?: string[],
)
| 370 | ); |
| 371 | |
| 372 | function checkIsOnPropertiesPatched( |
| 373 | target: any, |
| 374 | shouldPatchedProperties?: string[], |
| 375 | ignoredProperties?: string[], |
| 376 | ) { |
| 377 | let checkTargetProps = |
| 378 | shouldPatchedProperties && shouldPatchedProperties.map((p) => `on${p}`); |
| 379 | if (!checkTargetProps) { |
| 380 | checkTargetProps = []; |
| 381 | for (let prop in target) { |
| 382 | checkTargetProps.push(prop); |
| 383 | } |
| 384 | } |
| 385 | for (let i = 0; i < checkTargetProps.length; i++) { |
| 386 | const prop = checkTargetProps[i]; |
| 387 | if ( |
| 388 | ignoredProperties && |
| 389 | ignoredProperties.filter((ignoreProp) => ignoreProp === prop).length > 0 |
| 390 | ) { |
| 391 | continue; |
| 392 | } |
| 393 | if (prop.slice(0, 2) === 'on' && prop.length > 2) { |
| 394 | let propExistsOnTarget = false; |
| 395 | let checkTarget = target; |
| 396 | while (checkTarget && checkTarget !== Object) { |
| 397 | const desc = Object.getOwnPropertyDescriptor(checkTarget, prop); |
| 398 | if (desc && desc.configurable) { |
| 399 | propExistsOnTarget = true; |
| 400 | break; |
| 401 | } |
| 402 | checkTarget = Object.getPrototypeOf(checkTarget); |
| 403 | } |
| 404 | if (!propExistsOnTarget) { |
| 405 | //console.warn(`${prop} not exists on target ${target}`); |
| 406 | continue; |
| 407 | } |
| 408 | target[prop] = noop; |
| 409 | if (!target[Zone.__symbol__('ON_PROPERTY' + prop.slice(2))]) { |
| 410 | fail(`${prop} of ${target} is not patched`); |
| 411 | } else { |
| 412 | expect(target[prop]).toBe(noop); |
| 413 | target[prop] = null; |
| 414 | expect(target[Zone.__symbol__('ON_PROPERTY' + prop.slice(2))]).toBeNull(); |
| 415 | } |
| 416 | } |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | it('should patch all possible on properties on native prototype', function () { |
| 421 | function isPropertyPatched(obj: any, prop: string, prototype?: any) { |
no test coverage detected
searching dependent graphs…