Archived
1
0

Share common util code with VS Code

This lets us re-use the normalized base path so when we expire/clear the
cookie we use the same base path.
This commit is contained in:
Asher
2021-05-03 14:42:24 -05:00
parent 49c26f70f7
commit a48ac5080b
9 changed files with 32 additions and 34 deletions

View File

@ -18,9 +18,6 @@ global.document = dom.window.document
export type LocationLike = Pick<Location, "pathname" | "origin">
// jest.mock is hoisted above the imports so we must use `require` here.
jest.mock("@coder/logger", () => require("../utils/helpers").loggerModule)
describe("util", () => {
describe("normalize", () => {
it("should remove multiple slashes", () => {
@ -236,14 +233,14 @@ describe("util", () => {
const message = "You don't have access to that folder."
const error = new Error(message)
logError("ui", error)
logError(loggerModule.logger, "ui", error)
expect(loggerModule.logger.error).toHaveBeenCalled()
expect(loggerModule.logger.error).toHaveBeenCalledWith(`ui: ${error.message} ${error.stack}`)
})
it("should log an error, even if not an instance of error", () => {
logError("api", "oh no")
logError(loggerModule.logger, "api", "oh no")
expect(loggerModule.logger.error).toHaveBeenCalled()
expect(loggerModule.logger.error).toHaveBeenCalledWith("api: oh no")

View File

@ -1,3 +1,4 @@
import { logger } from "@coder/logger"
import * as express from "express"
import * as http from "http"
import * as net from "net"
@ -45,7 +46,7 @@ export class HttpServer {
rej(err)
} else {
// Promise resolved earlier so this is some other error.
util.logError("http server error", err)
util.logError(logger, "http server error", err)
}
})
})