Skip to content

Commit

Permalink
fix-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
uriva committed Nov 23, 2024
1 parent aabc5c0 commit 8cc38c0
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/taskBouncer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@ import type { Server } from "node:http";
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import { bouncerServer, staticFileEndpoint } from "./taskBouncer.ts";

let currentPort = 1234;
const getDistinctPortNumber = () => {
return (currentPort++).toString();
};

Deno.test("init", async () => {
const server = await bouncerServer("http://localhost", "1234", []);
const server = await bouncerServer(
"http://localhost",
getDistinctPortNumber(),
[],
);
await closeServer(server);
});

Deno.test("static endpoint", async () => {
const fileText = "<div>hello</div>";
const host = "http://localhost";
const port = "1234";
const port = getDistinctPortNumber();
const server = await bouncerServer(host, port, [
staticFileEndpoint(fileText, "text/html", "/hello"),
]);
Expand Down Expand Up @@ -40,7 +49,7 @@ const promiseWithResolver = () => {

Deno.test("cors", async () => {
const host = "http://localhost";
const port = "1234";
const port = getDistinctPortNumber();
const url = `${host}:${port}`;
const { promise: handlerRan, resolve: onHandlerRan } = promiseWithResolver();
const server = await bouncerServer(url, port, [{
Expand All @@ -62,7 +71,7 @@ Deno.test("cors", async () => {

Deno.test("cors preflight", async () => {
const host = "http://localhost";
const port = "1234";
const port = getDistinctPortNumber();
const server = await bouncerServer(host, port, [{
bounce: true,
predicate: () => true,
Expand Down

0 comments on commit 8cc38c0

Please sign in to comment.