mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-04 13:04:12 +00:00
ac2db38742
This removes circular dependencies between the device-api module and the compose module, reducing total circular dependencies to 15 Change-type: patch
31 lines
785 B
TypeScript
31 lines
785 B
TypeScript
import type * as express from 'express';
|
|
import request from 'supertest';
|
|
|
|
import * as apiKeys from '~/lib/api-keys';
|
|
import * as deviceApi from '~/src/device-api';
|
|
|
|
describe('device-api/index', () => {
|
|
let api: express.Application;
|
|
|
|
before(async () => {
|
|
api = new deviceApi.SupervisorAPI({
|
|
routers: [],
|
|
healthchecks: [],
|
|
// @ts-expect-error extract private variable for testing
|
|
}).api;
|
|
// Express app set in SupervisorAPI is private here
|
|
// but we need to access it for supertest
|
|
});
|
|
|
|
describe('/ping', () => {
|
|
it('responds with 200 regardless of auth', async () => {
|
|
await request(api).get('/ping').expect(200);
|
|
|
|
await request(api)
|
|
.get('/ping')
|
|
.set('Authorization', `Bearer ${await apiKeys.getGlobalApiKey()}`)
|
|
.expect(200);
|
|
});
|
|
});
|
|
});
|