// Copyright (c) 2026 Gordon Bolton. MIT License. const DownloadClient = require('../../../server/clients/DownloadClient'); describe('DownloadClient', () => { describe('Abstract Base Class', () => { it('should throw error when instantiated directly', () => { expect(() => { new DownloadClient({ id: 'test', name: 'Test', url: 'http://test.com' }); }).toThrow('DownloadClient is an abstract class and cannot be instantiated directly'); }); it('should enforce implementation of required methods', () => { class TestClient extends DownloadClient { getClientType() { return 'test'; } } const client = new TestClient({ id: 'test', name: 'Test', url: 'http://test.com' }); expect(() => client.testConnection()).rejects.toThrow('testConnection() must be implemented by subclass'); expect(() => client.getActiveDownloads()).rejects.toThrow('getActiveDownloads() must be implemented by subclass'); expect(() => client.normalizeDownload({})).toThrow('normalizeDownload() must be implemented by subclass'); }); }); describe('Base Properties', () => { class TestClient extends DownloadClient { getClientType() { return 'test'; } async testConnection() { return true; } async getActiveDownloads() { return []; } normalizeDownload(download) { return download; } } it('should set basic properties from config', () => { const config = { id: 'test-instance', name: 'Test Instance', url: 'http://test.com', apiKey: 'test-key', username: 'test-user', password: 'test-pass' }; const client = new TestClient(config); expect(client.id).toBe('test-instance'); expect(client.name).toBe('Test Instance'); expect(client.url).toBe('http://test.com'); expect(client.apiKey).toBe('test-key'); expect(client.username).toBe('test-user'); expect(client.password).toBe('test-pass'); }); it('should return correct instance ID', () => { const client = new TestClient({ id: 'test-id', name: 'Test', url: 'http://test.com' }); expect(client.getInstanceId()).toBe('test-id'); }); it('should have optional getClientStatus method returning null', async () => { const client = new TestClient({ id: 'test', name: 'Test', url: 'http://test.com' }); const status = await client.getClientStatus(); expect(status).toBeNull(); }); }); });