import { injectable } from 'inversify';
import { IStore } from './i-store';

/**
 * This mock store saves the data in memory.
 */
@injectable()
export class StoreMock implements IStore {
  private store: { [x in StoreKey]?: unknown } = {};

  public load(key: StoreKey): Promise<unknown> {
    return Promise.resolve(this.store[key]);
  }

  public save(key: StoreKey, data: unknown): Promise<void> {
    this.store[key] = data;
    return Promise.resolve();
  }
}
