-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Elmer Bulthuis
committed
May 6, 2024
1 parent
8a0bfa2
commit 88a0c56
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
packages/npm/reverse/src/operation-handlers/reverse.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters