fix: convert all test files from jest to vitest and fix QBittorrentClient import
Some checks failed
CI / Security audit (push) Failing after 19s
Licence Check / Licence compatibility and copyright header verification (push) Successful in 1m1s
Build and Push Docker Image / build (push) Successful in 1m10s
CI / Tests & coverage (push) Failing after 1m21s

- Convert RTorrentClient.test.js to use vi.mock() instead of jest.mock()
- Convert QBittorrentClient.test.js to use vi.mock() instead of jest.mock()
- Convert SABnzbdClient.test.js to use vi.mock() instead of jest.mock()
- Convert TransmissionClient.test.js to use vi.mock() instead of jest.mock()
- Convert downloadClients.test.js to use vi.mock() instead of jest.mock()
- Convert integration/downloadClients.test.js to use vi.mock() instead of jest.mock()
- Fix legacy qbittorrent.test.js to import QBittorrentClient from new location
- Add getRtorrentInstances mock to downloadClients.test.js
- Add RTORRENT_INSTANCES to integration test environment variables
This commit is contained in:
2026-05-19 12:12:44 +01:00
parent e39f15d3d8
commit cc0e34b3d1
7 changed files with 89 additions and 71 deletions

View File

@@ -1,10 +1,11 @@
// Copyright (c) 2026 Gordon Bolton. MIT License.
const {
const {
initializeClients,
getAllDownloads,
getDownloadsByClientType,
testAllConnections
} = require('../../server/utils/downloadClients');
const { vi } = require('vitest');
// Mock environment variables for testing
process.env.SABNZBD_INSTANCES = JSON.stringify([
@@ -36,10 +37,20 @@ process.env.TRANSMISSION_INSTANCES = JSON.stringify([
}
]);
process.env.RTORRENT_INSTANCES = JSON.stringify([
{
id: 'test-rtorrent',
name: 'Test rTorrent',
url: 'http://localhost:8080/RPC2',
username: 'rtorrent',
password: 'rtorrent'
}
]);
// Mock axios to prevent actual network calls
jest.mock('axios');
jest.mock('../../server/utils/logger', () => ({
logToFile: jest.fn()
vi.mock('axios');
vi.mock('../../server/utils/logger', () => ({
logToFile: vi.fn()
}));
describe('Download Clients Integration Tests', () => {