Move stubs from ./stubs to ./shared/Stubs
Gathers all shared test code in single place.
This commit is contained in:
23
tests/unit/shared/Stubs/ScriptCompilerStub.ts
Normal file
23
tests/unit/shared/Stubs/ScriptCompilerStub.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ScriptData } from 'js-yaml-loader!@/*';
|
||||
import { IScriptCompiler } from '@/application/Parser/Script/Compiler/IScriptCompiler';
|
||||
import { IScriptCode } from '@/domain/IScriptCode';
|
||||
|
||||
export class ScriptCompilerStub implements IScriptCompiler {
|
||||
public compilables = new Map<ScriptData, IScriptCode>();
|
||||
|
||||
public canCompile(script: ScriptData): boolean {
|
||||
return this.compilables.has(script);
|
||||
}
|
||||
|
||||
public compile(script: ScriptData): IScriptCode {
|
||||
return this.compilables.get(script);
|
||||
}
|
||||
|
||||
public withCompileAbility(script: ScriptData, result?: IScriptCode): ScriptCompilerStub {
|
||||
this.compilables.set(
|
||||
script,
|
||||
result || { execute: `compiled code of ${script.name}`, revert: `compiled revert code of ${script.name}` },
|
||||
);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user