Skip to content

Commit 990b743

Browse files
minor refactoring
1 parent 3ceef2f commit 990b743

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/SubstituteBase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class SubstituteJS {
77
this._lastRegisteredSubstituteJSMethodOrProperty = value;
88
}
99
get lastRegisteredSubstituteJSMethodOrProperty() {
10-
return typeof this._lastRegisteredSubstituteJSMethodOrProperty === 'undefined' ? 'root' : this._lastRegisteredSubstituteJSMethodOrProperty;
10+
return this._lastRegisteredSubstituteJSMethodOrProperty ?? 'root';
1111
}
1212
[Symbol.toPrimitive]() {
1313
return `[class ${this.constructor.name}] -> ${this.lastRegisteredSubstituteJSMethodOrProperty}`;

src/Utilities.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import { Argument, AllArguments } from './Arguments';
2-
import { GetPropertyState } from './states/GetPropertyState';
3-
import { InitialState } from './states/InitialState';
4-
import { Context } from './Context';
52
import * as util from 'util';
63

74
export type Call = any[] // list of args
@@ -11,7 +8,7 @@ export enum PropertyType {
118
property = 'property'
129
}
1310

14-
export enum SubstituteMethods {
11+
export enum SubstituteMethod {
1512
received = 'received',
1613
didNotReceive = 'didNotReceive',
1714
mimicks = 'mimicks',
@@ -21,6 +18,14 @@ export enum SubstituteMethods {
2118
rejects = 'rejects'
2219
}
2320

21+
export function isSubstituteMethod(property: PropertyKey): property is SubstituteMethod {
22+
return property === SubstituteMethod.returns ||
23+
property === SubstituteMethod.mimicks ||
24+
property === SubstituteMethod.throws ||
25+
property === SubstituteMethod.resolves ||
26+
property === SubstituteMethod.rejects;
27+
}
28+
2429
const seenObject = Symbol();
2530

2631
export function stringifyArguments(args: any[]) {

0 commit comments

Comments
 (0)