23 lines
854 B
JavaScript
23 lines
854 B
JavaScript
import { describe, it, expect, beforeAll } from 'vitest';
|
|
import request from 'supertest';
|
|
import { setup } from './helpers.js';
|
|
|
|
let app, ownerHeaders;
|
|
beforeAll(async () => { ({ app, ownerHeaders } = await setup()); });
|
|
|
|
describe('host api', () => {
|
|
it('401 without auth', async () => {
|
|
expect((await request(app).get('/api/host')).status).toBe(401);
|
|
});
|
|
it('returns cpu/mem/disk/net shape', async () => {
|
|
const res = await request(app).get('/api/host').set(ownerHeaders);
|
|
expect(res.status).toBe(200);
|
|
expect(res.body.cpu_pct).toBeGreaterThanOrEqual(0);
|
|
expect(res.body.cpu_pct).toBeLessThanOrEqual(100);
|
|
expect(res.body.mem.total).toBeGreaterThan(0);
|
|
expect(res.body.mem.used).toBeGreaterThanOrEqual(0);
|
|
expect(res.body.disk).toHaveProperty('pct');
|
|
expect(res.body.net).toHaveProperty('rx_bytes');
|
|
});
|
|
});
|