diff --git a/packages/npm/reverse/src/operation-handlers/reverse.test.ts b/packages/npm/reverse/src/operation-handlers/reverse.test.ts new file mode 100644 index 0000000..cf44b9e --- /dev/null +++ b/packages/npm/reverse/src/operation-handlers/reverse.test.ts @@ -0,0 +1,28 @@ +import assert from "assert"; +import test from "node:test"; +import * as api from "reverse-api"; +import * as operationHandlers from "../operation-handlers/index.js"; + +test("reverse", async () => { + const server = new api.Server(); + + // register only one operation handler + server.registerReverseOperation(operationHandlers.reverse); + + await using listener = await api.lib.listen(server); + + const result = await api.reverse( + { + contentType: "text/plain", + value: () => "123", + }, + {}, + { baseUrl: new URL(`http://localhost:${listener.port}`) }, + ); + + assert(result.status === 200); + + const resultValue = await result.value(); + + assert.equal(resultValue, "321"); +}); diff --git a/scripts/generate.js b/scripts/generate.js index 7e88014..f277fd2 100755 --- a/scripts/generate.js +++ b/scripts/generate.js @@ -26,4 +26,7 @@ for (const name of names) { ], options, ); + + cp.execFileSync("npm", ["--workspace", name, "ci"], options); + cp.execFileSync("npm", ["--workspace", name, "run", "build"], options); }