Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/FoxxMD/multi-scrobbler. Scrobble plays from multiple sources to multiple clients docs.multi-scrobbler.app
deezer docker jellyfin koito lastfm listenbrainz maloja mopidy mpris music music-assistant plex scrobble self-hosted spotify subsonic tautulli youtube-music
Something went wrong. Try again.
2.6 kB · 64 lines
TypeScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465import { expect } from 'chai';import { describe, it } from 'mocha';import request from 'supertest';import { loggerTest } from '@foxxmd/logging';import ScrobbleSources from '../../sources/ScrobbleSources.ts';import ScrobbleClients from '../../scrobblers/ScrobbleClients.ts';import { WildcardEmitter } from '../../common/WildcardEmitter.ts';import { initServer } from '../../server/index.ts';import type { ListenbrainzEndpointSourceConfig } from '../../common/infrastructure/config/source/endpointlz.ts';
const internalConfig = { localUrl: new URL('https://example.com'), configDir: 'fake', logger: loggerTest, version: 'test' };
const defaultLzConfig: ListenbrainzEndpointSourceConfig & { source: string } = { id: 'test', enable: true, data: {}, source: 'file'};
const buildApp = async () => { const sources = new ScrobbleSources(new WildcardEmitter(), internalConfig, loggerTest); await sources.addSource('endpointlz', [defaultLzConfig]); const clients = new ScrobbleClients(new WildcardEmitter(), new WildcardEmitter(), internalConfig, loggerTest); const [app] = await initServer({ sources, clients }, { testMode: true }); return app;};
describe('Health Endpoint', function () {
it('accepts a request with no query parameters', async function () { const response = await request(await buildApp()).get('/api/health');
expect(response.status).to.not.eq(400); expect(response.body).to.have.property('messages'); });
it('accepts a request filtered by type and name', async function () { const response = await request(await buildApp()) .get('/api/health') .query({ type: 'endpointlz', name: 'test' });
expect(response.status).to.not.eq(400); expect(response.body).to.have.property('messages'); });
it('accepts a request filtered by only one of type or name', async function () { const app = await buildApp();
for (const query of [{ type: 'endpointlz' }, { name: 'test' }]) { const response = await request(app).get('/api/health').query(query); expect(response.status, JSON.stringify(query)).to.not.eq(400); expect(response.body, JSON.stringify(query)).to.have.property('messages'); } });
it('follows the /health redirect while preserving the query string', async function () { const response = await request(await buildApp()) .get('/health?type=endpointlz') .redirects(1);
expect(response.status).to.not.eq(400); expect(response.body).to.have.property('messages'); });});