chore: harden release checks and package coverage
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/syntax",
|
||||
"version": "0.8.13",
|
||||
"version": "0.8.15",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"exports": {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { hasRequestSection, parseApiEntries, parseApiSections } from "../src/api-sections.ts";
|
||||
|
||||
test("api section scanning ignores keywords in literals, comments, and nested objects", () => {
|
||||
const source = `
|
||||
// request { body { forged: string } }
|
||||
response {
|
||||
return { label: "request { not a section }", nested: { body: true } }
|
||||
}
|
||||
`;
|
||||
expect(hasRequestSection(source)).toBe(false);
|
||||
expect(parseApiSections(source)?.response).toContain("nested");
|
||||
});
|
||||
|
||||
test("api entries normalize methods and reject malformed request fields", () => {
|
||||
expect(
|
||||
parseApiEntries(`lookup get /users/:id {
|
||||
response { return data }
|
||||
}`)[0],
|
||||
).toMatchObject({
|
||||
name: "lookup",
|
||||
method: "GET",
|
||||
path: "/users/:id",
|
||||
});
|
||||
expect(() =>
|
||||
parseApiSections("request { body { missingType } } response { return data }"),
|
||||
).toThrow('Expected "name: type"');
|
||||
});
|
||||
Reference in New Issue
Block a user