Skip to content

Commit cd8d1fc

Browse files
committed
WIP validate post record
1 parent ee83c96 commit cd8d1fc

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

packages/core/src/node.test.ts

+28-24
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { NodeRegistry } from "./node-registry.ts";
44
import { assertEquals, assertObjectMatch } from "jsr:@std/assert";
55
import { bootstrap } from "@needle-di/core";
66
import { Lexicons } from "@atproto/lexicon";
7+
import { skip } from "node:test";
78

89
function assertSuccessfullResolution(
910
data: Resolution,
@@ -92,27 +93,30 @@ Deno.test("doesn't resolve the same uri twice", async () => {
9293
assertEquals(new Set(duplicateUris), new Set());
9394
});
9495

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-
});
96+
Deno.test,
97+
skip("can validate a post record", async () => {
98+
const NSID_STR = "app.bsky.feed.post";
99+
const registry = bootstrap(NodeRegistry);
100+
const resolutions = [];
101+
for await (
102+
const resolution of registry.resolve([
103+
registry.get(NSID.parse(NSID_STR)),
104+
])
105+
) {
106+
assertSuccessfullResolution(resolution);
107+
resolutions.push(resolution);
108+
}
109+
110+
const lexicons = new Lexicons(resolutions.map((r) => r.doc));
111+
112+
const exampleRecords = [
113+
'{"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"}}',
114+
'{"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"}}',
115+
].map((s) => JSON.parse(s).value);
116+
117+
for (const exampleRecord of exampleRecords) {
118+
const result = lexicons.validate(NSID_STR, exampleRecord);
119+
// @ts-expect-error result.error isn't narrowed
120+
assertEquals(result.success, true, `Failed to validate: ${result.error}`);
121+
}
122+
});

0 commit comments

Comments
 (0)