File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export class FunctionToString implements Integration {
2121 originalFunctionToString = Function . prototype . toString ;
2222
2323 Function . prototype . toString = function ( this : WrappedFunction , ...args : any [ ] ) : string {
24- const context = this . __sentry__ ? this . __sentry_original__ : this ;
24+ const context = this . __sentry_original__ || this ;
2525 // tslint:disable-next-line:no-unsafe-any
2626 return originalFunctionToString . apply ( context , args ) ;
2727 } ;
Original file line number Diff line number Diff line change 1+ import { fill } from '../../../../utils/src/object' ;
2+ import { FunctionToString } from '../../../src/integrations/functiontostring' ;
3+
4+ describe ( 'FunctionToString' , ( ) => {
5+ it ( 'it works as expected' , ( ) => {
6+ const foo = {
7+ bar ( wat : boolean ) : boolean {
8+ return wat ;
9+ } ,
10+ } ;
11+ const originalFunction = foo . bar . toString ( ) ;
12+ fill ( foo , 'bar' , function wat ( whatever : boolean ) : ( ) => void {
13+ return function watwat ( ) : boolean {
14+ return whatever ;
15+ } ;
16+ } ) ;
17+
18+ expect ( foo . bar . toString ( ) ) . not . toBe ( originalFunction ) ;
19+
20+ const fts = new FunctionToString ( ) ;
21+ fts . setupOnce ( ) ;
22+
23+ expect ( foo . bar . toString ( ) ) . toBe ( originalFunction ) ;
24+ } ) ;
25+ } ) ;
You can’t perform that action at this time.
0 commit comments