/**
 * Test helpers for @bytelyst/storage.
 */

import { setStorage, _resetStorage } from './factory.js';
import { MemoryStorageProvider } from './providers/memory.js';

let _testProvider: MemoryStorageProvider | null = null;

export function setTestStorageProvider(): MemoryStorageProvider {
  _testProvider = new MemoryStorageProvider();
  setStorage(_testProvider);
  return _testProvider;
}

export function clearTestStorage(): void {
  _testProvider?.clear();
}

export function resetTestStorage(): void {
  _testProvider?.clear();
  _testProvider = null;
  _resetStorage();
}
