30 lines
937 B
TypeScript
30 lines
937 B
TypeScript
import { expect, test } from "../support/browser/strict-browser-test.ts";
|
|
|
|
test("executes the storage durability adapter against the real browser StorageManager", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto("/");
|
|
const result = await page.evaluate(async () => {
|
|
const modulePath =
|
|
"/src/adapters/browser-file-storage/storage-manager-adapter.ts";
|
|
const { createStorageDurabilityAdapter } = await import(
|
|
/* @vite-ignore */ modulePath
|
|
);
|
|
const adapter = createStorageDurabilityAdapter(navigator.storage);
|
|
return adapter.inspect();
|
|
});
|
|
|
|
expect(result.ok).toBe(true);
|
|
if (result.ok) {
|
|
expect(["UNKNOWN", "NORMAL", "PRESSURE", "CRITICAL"]).toContain(
|
|
result.value.pressure,
|
|
);
|
|
expect(
|
|
result.value.usageBytes === null || result.value.usageBytes >= 0,
|
|
).toBe(true);
|
|
expect(
|
|
result.value.quotaBytes === null || result.value.quotaBytes >= 0,
|
|
).toBe(true);
|
|
}
|
|
});
|