Rust implementation of NextGraph, a Decentralized and local-first web 3.0 ecosystem https://nextgraph.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nextgraph-rs/sdk/ng-sdk-js/ng-ldo-compact/packages/schema-converter-shex/test/typing.compact.test.ts

28 lines
963 B

import parser from "@shexjs/parser";
import { testData } from "./testData/testData.js";
import { shexjToTyping } from "../src/typing/shexjToTyping.js";
import type { Schema } from "shexj";
console.warn = () => {};
describe("typing-compact", () => {
testData.forEach((td) => {
const { name, shexc, successfulCompactTypings } = td;
if (!successfulCompactTypings) return; // skip if neither
it(`Creates compact typings for ${name}`, async () => {
const schema: Schema = parser
.construct("https://ldo.js.org/")
.parse(shexc);
const [compact] = await shexjToTyping(schema, { format: "compact" });
const normalize = (s: string) =>
s
.replace(/\r\n/g, "\n")
.replace(/\n+$/s, "\n")
// Ignore leading indentation differences
.replace(/^ +/gm, "");
expect(normalize(compact.typingsString)).toBe(
normalize(successfulCompactTypings)
);
});
});
});