import {AbsMessage} from 'scriptable-abstract'; interface MessageState { recipients: string[]; body: string; } const DEFAULT_STATE: MessageState = { recipients: [], body: '', }; /** * Mock implementation of Scriptable's Message. * Provides functionality for sending messages. * @implements Message */ export class MockMessage extends AbsMessage { private static _instance: MockMessage | null = null; static get instance(): MockMessage { if (!this._instance) { this._instance = new MockMessage(); } return this._instance; } constructor() { super(DEFAULT_STATE); } get recipients(): string[] { return [...this.state.recipients]; } set recipients(value: string[]) { this.setState({recipients: [...value]}); } get body(): string { return this.state.body; } set body(value: string) { this.setState({body: value}); } /** * Send the message. * @returns A promise that resolves when the message is sent */ async send(): Promise { // In a mock environment, we'll simulate successful message sending return Promise.resolve(); } /** * Clear the message details */ clear(): void { this.setState(DEFAULT_STATE); } }