import { LocationOps } from '@/infrastructure/CodeRunner/SystemOperations/SystemOperations'; import { StubWithObservableMethodCalls } from './StubWithObservableMethodCalls'; export class LocationOpsStub extends StubWithObservableMethodCalls implements LocationOps { private sequence = new Array(); private scenarios = new Map(); public withJoinResult(returnValue: string, ...paths: string[]): this { this.scenarios.set(LocationOpsStub.getScenarioKey(paths), returnValue); return this; } public withJoinResultSequence(...valuesToReturn: string[]): this { this.sequence.push(...valuesToReturn); this.sequence.reverse(); return this; } public combinePaths(...pathSegments: string[]): string { this.registerMethodCall({ methodName: 'combinePaths', args: pathSegments, }); const nextInSequence = this.sequence.pop(); if (nextInSequence) { return nextInSequence; } const key = LocationOpsStub.getScenarioKey(pathSegments); const foundScenario = this.scenarios.get(key); if (foundScenario) { return foundScenario; } return pathSegments.join('/PATH-SEGMENT-SEPARATOR/'); } private static getScenarioKey(paths: string[]): string { return paths.join('|'); } }