fix: convert test files to ES modules and fix qbittorrent test method calls
- Convert all client test files from CommonJS require() to ES module import syntax - Convert downloadClients.test.js and integration/downloadClients.test.js to ES modules - Fix qbittorrent.test.js to use getActiveDownloads() instead of getTorrents() - All test files now use proper Vitest-compatible ES module syntax - Resolves Vitest import errors and QBittorrentClient method call errors
This commit is contained in:
@@ -156,7 +156,7 @@ describe('QBittorrentClient sync API', () => {
|
||||
}
|
||||
});
|
||||
|
||||
const torrents = await client.getTorrents();
|
||||
const torrents = await client.getActiveDownloads();
|
||||
expect(torrents).toHaveLength(1);
|
||||
expect(torrents[0].name).toBe('Test1');
|
||||
expect(torrents[0].instanceId).toBe('test-qbt');
|
||||
@@ -188,7 +188,7 @@ describe('QBittorrentClient sync API', () => {
|
||||
}
|
||||
});
|
||||
|
||||
const torrents = await client.getTorrents();
|
||||
const torrents = await client.getActiveDownloads();
|
||||
expect(torrents).toHaveLength(1);
|
||||
expect(torrents[0].dlspeed).toBe(200);
|
||||
expect(torrents[0].name).toBe('Test1');
|
||||
@@ -219,7 +219,7 @@ describe('QBittorrentClient sync API', () => {
|
||||
}
|
||||
});
|
||||
|
||||
const torrents = await client.getTorrents();
|
||||
const torrents = await client.getActiveDownloads();
|
||||
expect(torrents).toHaveLength(1);
|
||||
expect(torrents[0].name).toBe('Test2');
|
||||
expect(torrents[0].hash).toBe('hash02');
|
||||
@@ -238,7 +238,7 @@ describe('QBittorrentClient sync API', () => {
|
||||
hash01: { name: 'Test1', state: 'downloading', size: 1000, progress: 0.5, dlspeed: 100, eta: 60, num_seeds: 5, num_leechs: 2, availability: 1.0 }
|
||||
}
|
||||
});
|
||||
await client.getTorrents();
|
||||
await client.getActiveDownloads();
|
||||
|
||||
mockSync(1, {
|
||||
rid: 2,
|
||||
@@ -246,7 +246,7 @@ describe('QBittorrentClient sync API', () => {
|
||||
torrents_removed: ['hash01']
|
||||
});
|
||||
|
||||
const torrents = await client.getTorrents();
|
||||
const torrents = await client.getActiveDownloads();
|
||||
expect(torrents).toHaveLength(0);
|
||||
});
|
||||
|
||||
@@ -267,7 +267,7 @@ describe('QBittorrentClient sync API', () => {
|
||||
{ name: 'Fallback', hash: 'fb01', state: 'downloading', size: 1073741824, progress: 0.5, dlspeed: 1048576, eta: 512, num_seeds: 10, num_leechs: 3, availability: 1.0 }
|
||||
]);
|
||||
|
||||
const torrents = await client.getTorrents();
|
||||
const torrents = await client.getActiveDownloads();
|
||||
expect(torrents).toHaveLength(1);
|
||||
expect(torrents[0].name).toBe('Fallback');
|
||||
expect(client.fallbackThisCycle).toBe(true);
|
||||
@@ -292,7 +292,7 @@ describe('QBittorrentClient sync API', () => {
|
||||
.get('/api/v2/sync/maindata?rid=0')
|
||||
.reply(200, { rid: 1, full_update: true });
|
||||
|
||||
const torrents = await client.getTorrents();
|
||||
const torrents = await client.getActiveDownloads();
|
||||
expect(torrents).toHaveLength(1);
|
||||
expect(torrents[0].name).toBe('DirectLegacy');
|
||||
expect(syncScope.isDone()).toBe(false);
|
||||
@@ -324,7 +324,7 @@ describe('QBittorrentClient sync API', () => {
|
||||
}
|
||||
});
|
||||
|
||||
const torrents = await client.getTorrents();
|
||||
const torrents = await client.getActiveDownloads();
|
||||
expect(torrents).toHaveLength(1);
|
||||
expect(torrents[0].name).toBe('AfterReauth');
|
||||
});
|
||||
@@ -342,7 +342,7 @@ describe('QBittorrentClient sync API', () => {
|
||||
}
|
||||
});
|
||||
|
||||
const torrents = await client.getTorrents();
|
||||
const torrents = await client.getActiveDownloads();
|
||||
expect(torrents[0].completed).toBe(500);
|
||||
});
|
||||
|
||||
@@ -363,7 +363,7 @@ describe('QBittorrentClient sync API', () => {
|
||||
|
||||
// Simulate the reset that getAllTorrents performs
|
||||
client.fallbackThisCycle = false;
|
||||
const torrents = await client.getTorrents();
|
||||
const torrents = await client.getActiveDownloads();
|
||||
expect(torrents[0].name).toBe('ResetWorks');
|
||||
expect(client.fallbackThisCycle).toBe(false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user