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,13 +1,14 @@
// Copyright (c) 2026 Gordon Bolton. MIT License.
const RTorrentClient = require('../../../server/clients/RTorrentClient');
const xmlrpc = require('xmlrpc');
const { vi } = require('vitest');
jest.mock('xmlrpc', () => ({
createClient: jest.fn()
vi.mock('xmlrpc', () => ({
createClient: vi.fn()
}));
jest.mock('../../../server/utils/logger', () => ({
logToFile: jest.fn()
vi.mock('../../../server/utils/logger', () => ({
logToFile: vi.fn()
}));
describe('RTorrentClient', () => {
@@ -16,7 +17,7 @@ describe('RTorrentClient', () => {
let mockMethodCall;
beforeEach(() => {
mockMethodCall = jest.fn();
mockMethodCall = vi.fn();
xmlrpc.createClient.mockReturnValue({
methodCall: mockMethodCall
});
@@ -30,7 +31,7 @@ describe('RTorrentClient', () => {
};
client = new RTorrentClient(mockConfig);
jest.clearAllMocks();
vi.clearAllMocks();
});
describe('Constructor', () => {