@tsed/schema
Version:
JsonSchema module for Ts.ED Framework
49 lines (44 loc) • 1.02 kB
text/typescript
import {getSpec, OperationPath, Path} from "../../index.js";
describe("Path", () => {
it("should declare a path", () => {
("/path")
class MyController {
("POST", "/")
get() {}
}
expect(getSpec(MyController)).toEqual({
tags: [
{
name: "MyController"
}
],
paths: {
"/path": {
post: {
operationId: "myControllerGet",
parameters: [],
responses: {
"200": {
description: "Success"
}
},
tags: ["MyController"]
}
}
}
});
});
it("should throw error for unsupported usage", () => {
class Test {
test() {}
}
let actualError: any;
try {
// @ts-ignore
Path("/")(Test.prototype, "test", 0);
} catch (er) {
actualError = er;
}
expect(actualError.message).toEqual("Path cannot be used as parameter decorator on Test.test.[0]");
});
});