mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-04 20:02:26 +00:00
Fix webtorrent-regression.test.mjs failures
- Added import of `setup-localstorage.mjs` to polyfill `self` required by `webtorrent.min.js`. - Updated `MockTorrent` to simulate webseed `wire` events, ensuring `probePeers` logic (which listens for wires) functions correctly in tests. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
c82ab2d490
commit
18bb9c244e
1 file changed
+13
@@ -1,4 +1,5 @@
|
||||
|
||||
import "./test-helpers/setup-localstorage.mjs";
|
||||
import { test, describe, it, after, before } from "node:test";
|
||||
import assert from "node:assert";
|
||||
import EventEmitter from "events";
|
||||
@@ -36,6 +37,18 @@ class MockTorrent extends EventEmitter {
|
||||
this.opts = opts;
|
||||
this.numPeers = 0;
|
||||
this.files = [];
|
||||
this.wires = [];
|
||||
|
||||
// Simulate webseeds if provided in opts
|
||||
if (opts && Array.isArray(opts.urlList) && opts.urlList.length > 0) {
|
||||
// Create mock wires for webseeds
|
||||
this.wires = opts.urlList.map(url => ({ type: 'webSeed' }));
|
||||
|
||||
// Emit wire events asynchronously to simulate connection
|
||||
setTimeout(() => {
|
||||
this.wires.forEach(wire => this.emit('wire', wire));
|
||||
}, 5);
|
||||
}
|
||||
}
|
||||
|
||||
destroy(opts, cb) {
|
||||
|
||||
Reference in new issue
Block a user