Move stubs from ./stubs to ./shared/Stubs
Gathers all shared test code in single place.
This commit is contained in:
20
tests/unit/shared/Stubs/CodeSubstituterStub.ts
Normal file
20
tests/unit/shared/Stubs/CodeSubstituterStub.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { IProjectInformation } from '@/domain/IProjectInformation';
|
||||
import { ICodeSubstituter } from '@/application/Parser/ScriptingDefinition/ICodeSubstituter';
|
||||
|
||||
export class CodeSubstituterStub implements ICodeSubstituter {
|
||||
private readonly scenarios =
|
||||
new Array<{ code: string, info: IProjectInformation, result: string }>();
|
||||
|
||||
public substitute(code: string, info: IProjectInformation): string {
|
||||
const scenario = this.scenarios.find((s) => s.code === code && s.info === info);
|
||||
if (scenario) {
|
||||
return scenario.result;
|
||||
}
|
||||
return `[CodeSubstituterStub] - code: ${code}`;
|
||||
}
|
||||
|
||||
public setup(code: string, info: IProjectInformation, result: string) {
|
||||
this.scenarios.push({ code, info, result });
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user