import { expect } from 'vitest'; import type { ScriptSelection } from '@/application/Context/State/Selection/Script/ScriptSelection'; import type { SelectedScript } from '@/application/Context/State/Selection/Script/SelectedScript'; import type { Script } from '@/domain/Executables/Script/Script'; import type { ScriptSelectionChange, ScriptSelectionChangeCommand } from '@/application/Context/State/Selection/Script/ScriptSelectionChange'; import { formatAssertionMessage } from '@tests/shared/FormatAssertionMessage'; import type { ExecutableId } from '@/domain/Executables/Identifiable'; import { StubWithObservableMethodCalls } from './StubWithObservableMethodCalls'; import { EventSourceStub } from './EventSourceStub'; import { SelectedScriptStub } from './SelectedScriptStub'; export class ScriptSelectionStub extends StubWithObservableMethodCalls implements ScriptSelection { public readonly changed = new EventSourceStub(); public selectedScripts: readonly SelectedScript[] = []; public isSelectedResult: boolean | undefined; public withSelectedScripts(selectedScripts: readonly SelectedScript[]): this { this.selectedScripts = selectedScripts; return this; } public triggerSelectionChangedEvent(scripts: readonly SelectedScript[]): this { this.changed.notify(scripts); return this; } public withIsSelectedResult(isSelected: boolean): this { this.isSelectedResult = isSelected; return this; } public isScriptSelected(scriptExecutableId: ExecutableId, revert: boolean): boolean { return this.isScriptChanged({ scriptId: scriptExecutableId, newStatus: { isSelected: true, isReverted: revert, }, }); } public isScriptDeselected(scriptExecutableId: ExecutableId): boolean { return this.isScriptChanged({ scriptId: scriptExecutableId, newStatus: { isSelected: false, }, }); } public processChanges(action: ScriptSelectionChangeCommand): void { this.registerMethodCall({ methodName: 'processChanges', args: [action], }); } public selectOnly(scripts: ReadonlyArray