mirror of
https://github.com/hay-kot/homebox.git
synced 2025-06-08 21:42:28 +00:00
testing + small fixes
This commit is contained in:
parent
3fda815634
commit
e73206875a
8 changed files with 358 additions and 91 deletions
|
@ -1,24 +1,8 @@
|
|||
import { describe, it, expect } from 'vitest';
|
||||
import { Requests } from '../../requests';
|
||||
import { OverrideParts } from '../base/urls';
|
||||
import { PublicApi } from '../public';
|
||||
import * as config from '../../../test/config';
|
||||
import { UserApi } from '../user';
|
||||
|
||||
function client() {
|
||||
OverrideParts(config.BASE_URL, '/api/v1');
|
||||
const requests = new Requests('');
|
||||
return new PublicApi(requests);
|
||||
}
|
||||
|
||||
function userClient(token: string) {
|
||||
OverrideParts(config.BASE_URL, '/api/v1');
|
||||
const requests = new Requests('', token);
|
||||
return new UserApi(requests);
|
||||
}
|
||||
import { describe, test, expect } from 'vitest';
|
||||
import { client, userClient } from './test-utils';
|
||||
|
||||
describe('[GET] /api/v1/status', () => {
|
||||
it('basic query parameter', async () => {
|
||||
test('server should respond', async () => {
|
||||
const api = client();
|
||||
const { response, data } = await api.status();
|
||||
expect(response.status).toBe(200);
|
||||
|
@ -37,12 +21,12 @@ describe('first time user workflow (register, login)', () => {
|
|||
},
|
||||
};
|
||||
|
||||
it('user should be able to register', async () => {
|
||||
test('user should be able to register', async () => {
|
||||
const { response } = await api.register(userData);
|
||||
expect(response.status).toBe(204);
|
||||
});
|
||||
|
||||
it('user should be able to login', async () => {
|
||||
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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue