This commit is contained in:
26
tests/unit/stubs/ExpressionStub.ts
Normal file
26
tests/unit/stubs/ExpressionStub.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { ExpressionPosition } from '@/application/Parser/Script/Compiler/Expressions/Expression/ExpressionPosition';
|
||||
import { ExpressionArguments, IExpression } from '@/application/Parser/Script/Compiler/Expressions/Expression/IExpression';
|
||||
|
||||
export class ExpressionStub implements IExpression {
|
||||
public callHistory = new Array<ExpressionArguments>();
|
||||
public position = new ExpressionPosition(0, 5);
|
||||
public parameters = [];
|
||||
private result: string;
|
||||
public withParameters(...parameters: string[]) {
|
||||
this.parameters = parameters;
|
||||
return this;
|
||||
}
|
||||
public withPosition(start: number, end: number) {
|
||||
this.position = new ExpressionPosition(start, end);
|
||||
return this;
|
||||
}
|
||||
public withEvaluatedResult(result: string) {
|
||||
this.result = result;
|
||||
return this;
|
||||
}
|
||||
public evaluate(args?: ExpressionArguments): string {
|
||||
this.callHistory.push(args);
|
||||
const result = this.result || `[expression-stub] args: ${args ? Object.keys(args).map((key) => `${key}: ${args[key]}`).join('", "') : 'none'}`;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user