Files
privacy.sexy/tests/unit/shared/Stubs/CollectionDataStub.ts
undergroundwires c138f74460 Refactor to unify scripts/categories as Executable
This commit consolidates scripts and categories under a unified
'Executable' concept. This simplifies the architecture and improves code
readability.

- Introduce subfolders within `src/domain` to segregate domain elements.
- Update class and interface names by removing the 'I' prefix in
  alignment with new coding standards.
- Replace 'Node' with 'Executable' to clarify usage; reserve 'Node'
  exclusively for the UI's tree component.
2024-06-12 12:36:40 +02:00

65 lines
1.8 KiB
TypeScript

import type {
CategoryData, ScriptData, CollectionData, ScriptingDefinitionData, FunctionData,
} from '@/application/collections/';
import { RecommendationLevel } from '@/domain/Executables/Script/RecommendationLevel';
import { ScriptingLanguage } from '@/domain/ScriptingLanguage';
import { createScriptDataWithCode } from './ScriptDataStub';
export class CollectionDataStub implements CollectionData {
public os = 'windows';
public actions: readonly CategoryData[] = [getCategoryStub()];
public scripting: ScriptingDefinitionData = getTestDefinitionStub();
public functions?: ReadonlyArray<FunctionData>;
public withActions(actions: readonly CategoryData[]): this {
this.actions = actions;
return this;
}
public withOs(os: string): this {
this.os = os;
return this;
}
public withScripting(scripting: ScriptingDefinitionData): this {
this.scripting = scripting;
return this;
}
public withFunctions(functions: ReadonlyArray<FunctionData>) {
this.functions = functions;
return this;
}
}
export function getCategoryStub(scriptPrefix = 'testScript'): CategoryData {
return {
category: 'category name',
children: [
getScriptStub(`${scriptPrefix}-standard`, RecommendationLevel.Standard),
getScriptStub(`${scriptPrefix}-strict`, RecommendationLevel.Strict),
],
};
}
function getTestDefinitionStub(): ScriptingDefinitionData {
return {
fileExtension: '.bat',
language: ScriptingLanguage[ScriptingLanguage.batchfile],
startCode: 'start',
endCode: 'end',
};
}
function getScriptStub(
scriptName: string,
level: RecommendationLevel = RecommendationLevel.Standard,
): ScriptData {
return createScriptDataWithCode()
.withName(scriptName)
.withRecommend(RecommendationLevel[level].toLowerCase());
}