testPublishedSchemasAreComparedByWhatTheySay
tcmts.dev.lexicons.test.testPublishedSchemasAreComparedByWhatTheySay · #q37lstl5 · term
import { sameSchema } from "#codebase/tcmts/dev/lexicons";
export const testPublishedSchemasAreComparedByWhatTheySay = () => {
const doc = {
lexicon: 1,
id: "codes.tcm.x",
defs: { main: { type: "token", description: "x" } },
};
const published = {
defs: { main: { description: "x", type: "token" } },
id: "codes.tcm.x",
lexicon: 1,
$type: "com.atproto.lexicon.schema",
};
if (!sameSchema(published, doc))
throw new Error("the same schema, its keys in another order, was taken as changed");
if (sameSchema({ ...published, defs: { main: { type: "token" } } }, doc))
throw new Error("a changed schema was taken as the same");
if (sameSchema(undefined, doc)) throw new Error("no record was taken as the same");
}
uses