import "@js-temporal/polyfill";
import "urlpattern-polyfill";
globalThis.addEventListener = () => {};
import { i as createRequestContext, t as test } from "../testing-BQeTO4ss.mjs";
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
import "../std__assert-2v7gYiZp.mjs";
import { t as MemoryKvStore } from "../kv-OuT2IU64.mjs";
import { a as createFederation, g as handleNodeInfoJrd, h as handleNodeInfo } from "../middleware-C26Vj2UM.mjs";
import { n as parseSemVer } from "../semver-CgD82xxg.mjs";
//#region src/nodeinfo/handler.test.ts
test("handleNodeInfo()", async () => {
	const request = new Request("https://example.com/nodeinfo/2.1");
	const context = createRequestContext({
		federation: createFederation({ kv: new MemoryKvStore() }),
		data: void 0,
		request,
		url: new URL(request.url)
	});
	const nodeInfoDispatcher = (_ctx) => ({
		software: {
			name: "test",
			version: parseSemVer("1.2.3")
		},
		protocols: ["activitypub"],
		usage: {
			users: {
				total: 3,
				activeHalfyear: 2,
				activeMonth: 1
			},
			localPosts: 123,
			localComments: 456
		}
	});
	const response = await handleNodeInfo(request, {
		context,
		nodeInfoDispatcher
	});
	assertEquals(response.status, 200);
	assertEquals(response.headers.get("Content-Type"), "application/json; profile=\"http://nodeinfo.diaspora.software/ns/schema/2.1#\"");
	assertEquals(await response.json(), {
		"$schema": "http://nodeinfo.diaspora.software/ns/schema/2.1#",
		version: "2.1",
		software: {
			name: "test",
			version: "1.2.3"
		},
		protocols: ["activitypub"],
		services: {
			inbound: [],
			outbound: []
		},
		openRegistrations: false,
		usage: {
			users: {
				total: 3,
				activeHalfyear: 2,
				activeMonth: 1
			},
			localPosts: 123,
			localComments: 456
		},
		metadata: {}
	});
});
test("handleNodeInfoJrd()", async () => {
	const request = new Request("https://example.com/.well-known/nodeinfo");
	let context = createRequestContext({
		federation: createFederation({ kv: new MemoryKvStore() }),
		data: void 0,
		request,
		url: new URL(request.url)
	});
	let response = await handleNodeInfoJrd(request, context);
	assertEquals(response.status, 200);
	assertEquals(response.headers.get("Content-Type"), "application/jrd+json");
	assertEquals(await response.json(), { links: [] });
	context = createRequestContext({
		...context,
		getNodeInfoUri() {
			return new URL("https://example.com/nodeinfo/2.1");
		}
	});
	response = await handleNodeInfoJrd(request, context);
	assertEquals(response.status, 200);
	assertEquals(response.headers.get("Content-Type"), "application/jrd+json");
	assertEquals(await response.json(), { links: [{
		href: "https://example.com/nodeinfo/2.1",
		rel: "http://nodeinfo.diaspora.software/ns/schema/2.1",
		type: "application/json; profile=\"http://nodeinfo.diaspora.software/ns/schema/2.1#\""
	}] });
});
//#endregion
export {};
