-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
1 changed file
with
5 additions
and
6 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,11 +1,10 @@ | ||
import axios from "npm:axios"; | ||
import type { Server } from "node:http"; | ||
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts"; | ||
import { bouncerServer, staticFileEndpoint } from "./taskBouncer.ts"; | ||
|
||
Deno.test("init", async () => { | ||
const server = await bouncerServer("http://localhost", "1234", []); | ||
server.close(); | ||
await closeServer(server); | ||
}); | ||
|
||
Deno.test("static endpoint", async () => { | ||
|
@@ -52,18 +51,18 @@ Deno.test("cors", async () => { | |
return Promise.resolve(); | ||
}, | ||
}]); | ||
// We are using axois here because it closes the connection, otherwise the test hangs. | ||
const response = await axios.get(`${url}/hello`, { | ||
const response = await fetch(`${url}/hello`, { | ||
headers: { "Origin": "http://example.com" }, | ||
}); | ||
assertEquals(response.headers["access-control-allow-origin"], "*"); | ||
assertEquals(response.headers.get("access-control-allow-origin"), "*"); | ||
await response.body?.cancel(); | ||
await handlerRan; | ||
await closeServer(server); | ||
}); | ||
|
||
Deno.test("cors preflight", async () => { | ||
const host = "http://localhost"; | ||
const port = "2222"; | ||
const port = "1234"; | ||
const server = await bouncerServer(host, port, [{ | ||
bounce: true, | ||
predicate: () => true, | ||
|