~james/core

core/web/src/lib/auth/agent.test.ts -rw-r--r-- 641 bytes
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 15 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { describe, expect, test } from "vitest";
import { hostForServiceDid, serviceDidForHost } from "#lib/auth/agent.ts";

describe("serviceDidForHost", () => {
	test.each([
		["migrator.example.com", "did:web:migrator.example.com"],
		["https://migrator.example.com/", "did:web:migrator.example.com"],
		["http://knot.example.com:8443", "did:web:knot.example.com%3A8443"]
	])("maps %s to %s", (input, expected) => {
		expect(serviceDidForHost(input)).toBe(expected);
	});

	test("round-trips with hostForServiceDid", () => {
		const host = "migrator.example.com";
		expect(hostForServiceDid(serviceDidForHost(host))).toBe(host);
	});
});