import { Volume, createFsFromVolume } from "memfs";
import { vi } from "vitest";
export function createMemFs(files = {}) {
    const vol = Volume.fromJSON(files, "/");
    const fs = createFsFromVolume(vol).promises;
    return {
        readFile: (p, encoding) => fs.readFile(p, encoding),
        writeFile: (p, data, options) => fs.writeFile(p, data, options),
        rename: (from, to) => fs.rename(from, to),
        mkdir: (p, options) => fs.mkdir(p, options),
        unlink: (p) => fs.unlink(p),
        realpath: (p) => fs.realpath(p),
    };
}
export function createMockCachedResource(bundledData) {
    const defaultResult = { data: bundledData, timestamp: 0 };
    const defaultStats = { memoryCacheSize: 0, memoryCacheMax: 0, cacheDir: "" };
    return {
        get: vi.fn()
            .mockResolvedValue(defaultResult),
        refresh: vi.fn()
            .mockResolvedValue(defaultResult),
        clear: vi.fn()
            .mockResolvedValue(undefined),
        stats: vi.fn()
            .mockReturnValue(defaultStats),
    };
}
