Skip to content

Commit ee83c96

Browse files
committed
Add post record test
1 parent 6ceb7c7 commit ee83c96

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

packages/core/src/node.test.ts

+26
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Resolution } from "./node.ts";
33
import { NodeRegistry } from "./node-registry.ts";
44
import { assertEquals, assertObjectMatch } from "jsr:@std/assert";
55
import { bootstrap } from "@needle-di/core";
6+
import { Lexicons } from "@atproto/lexicon";
67

78
function assertSuccessfullResolution(
89
data: Resolution,
@@ -90,3 +91,28 @@ Deno.test("doesn't resolve the same uri twice", async () => {
9091

9192
assertEquals(new Set(duplicateUris), new Set());
9293
});
94+
95+
Deno.test("can validate a post record", async () => {
96+
const NSID_STR = "app.bsky.feed.post";
97+
const registry = bootstrap(NodeRegistry);
98+
const resolutions = [];
99+
for await (
100+
const resolution of registry.resolve([
101+
registry.get(NSID.parse(NSID_STR)),
102+
])
103+
) {
104+
assertSuccessfullResolution(resolution);
105+
resolutions.push(resolution);
106+
}
107+
108+
const lexicons = new Lexicons(resolutions.map((r) => r.doc));
109+
110+
const exampleRecords = [
111+
'{"uri":"at://did:plc:2xau7wbgdq4phuou2ypwuen7/app.bsky.feed.post/3ljrsfbuuyk2g","cid":"bafyreigjrpyhhk5fibcajhhtkcefmxptntgx35t5zngvsxwwvu56hzioaq","value":{"text":"To update a globally installed CLI in deno you pass -fr\\n\\nfr fr","$type":"app.bsky.feed.post","langs":["en"],"createdAt":"2025-03-07T10:28:47.874Z"}}',
112+
'{"uri":"at://did:plc:yosojsta3nm5qiod5zqixzur/app.bsky.feed.post/3ljpreuc6fs2c","cid":"bafyreihyt2ckoxoyusimrexuxatuwazct7uiskukhspxic756inddofipy","value":{"text":"DOGE “seemed unsure” of what USAID programs they cut and is now attempting to reverse some of the cuts, says @propublica.org reporter Brett Murphy. “This is the opposite of a careful review.\\"","$type":"app.bsky.feed.post","embed":{"$type":"app.bsky.embed.video","video":{"$type":"blob","ref":{"$link":"bafkreidowys6ntilo4wslx23jishxiqfrwywqmxxer4sy2r6y5orwuosn4"},"mimeType":"video/mp4","size":8408607},"aspectRatio":{"width":1280,"height":720}},"langs":["en"],"facets":[{"$type":"app.bsky.richtext.facet","index":{"byteEnd":128,"byteStart":113},"features":[{"did":"did:plc:k4jt6heuiamymgi46yeuxtpt","$type":"app.bsky.richtext.facet#mention"}]}],"createdAt":"2025-03-06T15:05:20.412Z"}}',
113+
].map((s) => JSON.parse(s));
114+
115+
for (const exampleRecord of exampleRecords) {
116+
lexicons.validate(NSID_STR, exampleRecord);
117+
}
118+
});

0 commit comments

Comments
 (0)