refactor: move jest and add package.json to /test

This commit is contained in:
Joe Previte
2021-01-20 16:37:49 -07:00
parent 646ee3ad7f
commit 883dd13850
12 changed files with 3859 additions and 1824 deletions

View File

@ -1,4 +1,3 @@
import * as assert from "assert"
import * as express from "express"
import * as httpserver from "./httpserver"
import * as integration from "./integration"
@ -8,7 +7,7 @@ describe("proxy", () => {
const nhooyrDevServer = new httpserver.HttpServer()
let proxyPath: string
before(async () => {
beforeAll(async () => {
const e = express.default()
await nhooyrDevServer.listen(e)
e.get("/wsup", (req, res) => {
@ -20,7 +19,7 @@ describe("proxy", () => {
})
})
after(async () => {
afterAll(async () => {
await nhooyrDevServer.close()
})
@ -34,14 +33,16 @@ describe("proxy", () => {
it("should rewrite the base path", async () => {
;[, , codeServer] = await integration.setup(["--auth=none"], "")
const resp = await codeServer.fetch(proxyPath)
assert.equal(resp.status, 200)
assert.equal(await resp.json(), "asher is the best")
expect(resp.status).toBe(200)
const json = await resp.json()
expect(json).toBe("asher is the best")
})
it("should not rewrite the base path", async () => {
;[, , codeServer] = await integration.setup(["--auth=none", "--proxy-path-passthrough=true"], "")
const resp = await codeServer.fetch(proxyPath)
assert.equal(resp.status, 200)
assert.equal(await resp.json(), "joe is the best")
expect(resp.status).toBe(200)
const json = await resp.json()
expect(json).toBe("joe is the best")
})
})