test: add TS checks and fix issues
This commit is contained in:
@@ -71,6 +71,7 @@ describe("Caprover", () => {
|
||||
|
||||
describe("Initialization", () => {
|
||||
it("should throw an error when no domain is provided", () => {
|
||||
// @ts-ignore toThrowError exists¯\_(ツ)_/¯
|
||||
expect(() => new Caprover(new TestApp().eventStore, "")).toThrowError(
|
||||
"Missing domain or password"
|
||||
);
|
||||
@@ -78,6 +79,7 @@ describe("Caprover", () => {
|
||||
it("should throw an error when no password is provided", () => {
|
||||
expect(
|
||||
() => new Caprover(new TestApp().eventStore, CAPROVER_TEST_DOMAIN)
|
||||
// @ts-ignore toThrowError exists¯\_(ツ)_/¯
|
||||
).toThrowError("Missing domain or password");
|
||||
});
|
||||
});
|
||||
@@ -125,6 +127,7 @@ describe("Caprover", () => {
|
||||
it("should throw an error when the application does not exist and not emit any event", async () => {
|
||||
await expect(
|
||||
caprover.updateApplication("unknown", "adminer:4.2.0")
|
||||
// @ts-ignore toThrowError exists¯\_(ツ)_/¯
|
||||
).rejects.toThrowError(/Failed to update application unknown/);
|
||||
|
||||
const events = app.eventStore.getAllEvents();
|
||||
|
||||
@@ -133,14 +133,15 @@ class Caprover {
|
||||
await this.authenticate();
|
||||
|
||||
console.debug("-> Caprover Fetching", options?.method, path);
|
||||
|
||||
const headers = new Headers(options?.headers);
|
||||
headers.set("Content-Type", "application/json");
|
||||
headers.set("x-namespace", "captain");
|
||||
headers.set("x-captain-auth", this.authToken);
|
||||
|
||||
return fetch(`${this.apiUrl}${path}`, {
|
||||
...options,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...(options?.headers || {}),
|
||||
"x-namespace": "captain",
|
||||
"x-captain-auth": this.authToken,
|
||||
},
|
||||
headers: headers,
|
||||
}).then((res) => {
|
||||
console.debug(
|
||||
"\t<- Caprover Response",
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import {
|
||||
http,
|
||||
HttpResponse,
|
||||
HttpResponseResolver,
|
||||
PathParams
|
||||
} from "msw";
|
||||
import { setupServer } from "msw/node";
|
||||
import { http, HttpResponse, HttpResponseResolver, PathParams } from "msw";
|
||||
import appsFixtures from "./apps.fixtures.json";
|
||||
|
||||
export const CAPROVER_TEST_DOMAIN = "caprover.test";
|
||||
@@ -14,7 +19,7 @@ const withAuth = (resolver: HttpResponseResolver): HttpResponseResolver => {
|
||||
headers.get("x-namespace") !== "captain" ||
|
||||
headers.get("x-captain-auth") !== TEST_TOKEN
|
||||
) {
|
||||
return new HttpResponse("", { status: 401 });
|
||||
return HttpResponse.json({}, { status: 401 });
|
||||
}
|
||||
return resolver(input);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user