Skip to content

Commit 7007572

Browse files
committed
is substitute?
1 parent a325c47 commit 7007572

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Substitute.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ import { stringifyCalls, stringifyArguments } from "./Utilities";
44

55
const areProxiesDisabledKey = Symbol.for('areProxiesDisabled');
66
const handlerKey = Symbol.for('handler');
7+
const isFake = Symbol.for('isFake');
78

8-
const internalSymbols = [areProxiesDisabledKey, handlerKey];
9+
const internalSymbols = [areProxiesDisabledKey, handlerKey, isFake];
910

1011
export class Substitute {
12+
static isSubstitute<T>(instance: T) {
13+
return instance[isFake];
14+
}
15+
1116
static disableFor<T extends ObjectSubstitute<OmitProxyMethods<any>>>(substitute: T): DisabledSubstituteObject<T> {
1217
const thisProxy = substitute as any;
1318
const thisExposedProxy = thisProxy[handlerKey];
@@ -254,6 +259,7 @@ export class Substitute {
254259
thisProxy = new Proxy(() => { }, thisExposedProxy) as any;
255260

256261
thisProxy[areProxiesDisabledKey] = false;
262+
thisProxy[isFake] = true;
257263
thisProxy[handlerKey] = thisExposedProxy;
258264

259265
return thisProxy;

0 commit comments

Comments
 (0)