mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-18 21:16:31 +00:00
75c633dcb5
* dummy commit * cleanup workflows * setup and run eslint * add linter to CI * use eslint for formatting * reorder rules * drop editor config
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { describe, test, expect } from "vitest";
|
|
import { client, userClient } from "./test-utils";
|
|
|
|
describe("[GET] /api/v1/status", () => {
|
|
test("server should respond", async () => {
|
|
const api = client();
|
|
const { response, data } = await api.status();
|
|
expect(response.status).toBe(200);
|
|
expect(data.health).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe("first time user workflow (register, login)", () => {
|
|
const api = client();
|
|
const userData = {
|
|
groupName: "test-group",
|
|
user: {
|
|
email: "test-user@email.com",
|
|
name: "test-user",
|
|
password: "test-password",
|
|
},
|
|
};
|
|
|
|
test("user should be able to register", async () => {
|
|
const { response } = await api.register(userData);
|
|
expect(response.status).toBe(204);
|
|
});
|
|
|
|
test("user should be able to login", async () => {
|
|
const { response, data } = await api.login(userData.user.email, userData.user.password);
|
|
expect(response.status).toBe(200);
|
|
expect(data.token).toBeTruthy();
|
|
|
|
// Cleanup
|
|
const userApi = userClient(data.token);
|
|
{
|
|
const { response } = await userApi.deleteAccount();
|
|
expect(response.status).toBe(204);
|
|
}
|
|
});
|
|
});
|