import { Temporal } from "@js-temporal/polyfill";
import "urlpattern-polyfill";
globalThis.addEventListener = () => {};
import { t as test } from "../testing-D_x7wGM2.mjs";
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
import "../std__assert-2v7gYiZp.mjs";
import { t as MemoryKvStore } from "../kv-DM1zFCtL.mjs";
//#region src/federation/kv.test.ts
test("MemoryKvStore", async (t) => {
	const store = new MemoryKvStore();
	await t.step("set() & get()", async () => {
		await store.set(["foo", "bar"], "foobar");
		assertEquals(await store.get(["foo", "bar"]), "foobar");
		assertEquals(await store.get(["foo"]), void 0);
		await store.set(["foo", "baz"], "baz", { ttl: Temporal.Duration.from({ seconds: 0 }) });
		await new Promise((resolve) => setTimeout(resolve, 10));
		assertEquals(await store.get(["foo", "baz"]), void 0);
	});
	await t.step("delete()", async () => {
		await store.delete(["foo", "bar"]);
		assertEquals(await store.get(["foo", "bar"]), void 0);
	});
	await t.step("cas()", async () => {
		await store.set(["foo", "bar"], "foobar");
		assertEquals(await store.cas(["foo", "bar"], "bar", "baz"), false);
		assertEquals(await store.get(["foo", "bar"]), "foobar");
		assertEquals(await store.cas(["foo", "bar"], "foobar", "baz"), true);
		assertEquals(await store.get(["foo", "bar"]), "baz");
		await store.delete(["foo", "bar"]);
		assertEquals(await store.cas(["foo", "bar"], "foobar", "baz"), false);
		assertEquals(await store.get(["foo", "bar"]), void 0);
		assertEquals(await store.cas(["foo", "bar"], void 0, "baz"), true);
		assertEquals(await store.get(["foo", "bar"]), "baz");
	});
});
//#endregion
export {};
