/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import { AttachState } from "@fluidframework/container-definitions"; import { FluidHandleBase } from "@fluidframework/runtime-utils/internal"; /** * Mock implementation of IFluidHandle. * @legacy @beta */ export class MockHandle extends FluidHandleBase { private graphAttachState: AttachState = AttachState.Detached; public get isAttached(): boolean { return this.graphAttachState === AttachState.Attached; } constructor( protected readonly value: T, public readonly path = `mock-handle-${Math.random().toString(36).slice(2)}`, public readonly absolutePath: string = `/${path}`, ) { super(); } public async get(): Promise { return this.value; } public attachGraph(): void { this.graphAttachState = AttachState.Attached; } }