forked from kawarimidoll/bluestream
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils_test.ts
26 lines (21 loc) · 881 Bytes
/
utils_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { assertEquals } from "std/assert/mod.ts";
import { getDidFromUri, toUTCString, uriToPostLink } from "./utils.ts";
Deno.test("getDidFromUri", () => {
const src = "at://did:plc:user/app.bsky.feed.post/rkey";
const expected = "did:plc:user";
assertEquals(getDidFromUri(src), expected);
});
Deno.test("toUTCString", () => {
const src = "2023-01-23T01:23:45.678Z";
const expected = "Mon, 23 Jan 2023 01:23:45 GMT";
assertEquals(toUTCString(src), expected);
});
Deno.test("uriToPostLink", () => {
const src = "at://did:plc:user/app.bsky.feed.post/rkey";
// usePsky = false
const expectedBsky = "https://bsky.app/profile/did:plc:user/post/rkey";
assertEquals(uriToPostLink(src, false), expectedBsky);
// usePsky = true
const expectedPsky = "https://psky.app/profile/did:plc:user/post/rkey";
assertEquals(uriToPostLink(src, true), expectedPsky);
});