mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-10 14:52:57 +00:00
Merge pull request #2230 from PR0M3TH3AN/chore/refactor-fetchVideos-5572786315509686162
Refactor deprecated fetchVideos method
This commit is contained in:
2 files changed
+65
-75
No files matched your search
@@ -165,6 +165,53 @@ describe("NostrClient", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("fetchVideos", () => {
|
||||
it("should delegate to subscribeVideos and return result on eose", async () => {
|
||||
let subOpts = null;
|
||||
// Override subscribeVideos to verify delegation
|
||||
client.subscribeVideos = (cb, opts) => {
|
||||
subOpts = opts;
|
||||
return {
|
||||
on: (evt, handler) => {
|
||||
if (evt === "eose") setTimeout(handler, 0);
|
||||
},
|
||||
unsub: () => {},
|
||||
};
|
||||
};
|
||||
|
||||
// Mock helpers
|
||||
client.getActiveVideos = () => [{ id: "v1" }];
|
||||
client.populateNip71MetadataForVideos = async () => {};
|
||||
client.applyRootCreatedAt = () => {};
|
||||
|
||||
const result = await client.fetchVideos({ limit: 5 });
|
||||
assert.equal(result[0].id, "v1");
|
||||
assert.equal(subOpts.limit, 5);
|
||||
// Ensure we force full fetch by default
|
||||
assert.equal(subOpts.since, 0);
|
||||
});
|
||||
|
||||
it("should respect since parameter if provided", async () => {
|
||||
let subOpts = null;
|
||||
client.subscribeVideos = (cb, opts) => {
|
||||
subOpts = opts;
|
||||
return {
|
||||
on: (evt, handler) => {
|
||||
if (evt === "eose") setTimeout(handler, 0);
|
||||
},
|
||||
unsub: () => {},
|
||||
};
|
||||
};
|
||||
|
||||
client.getActiveVideos = () => [];
|
||||
client.populateNip71MetadataForVideos = async () => {};
|
||||
client.applyRootCreatedAt = () => {};
|
||||
|
||||
await client.fetchVideos({ since: 12345 });
|
||||
assert.equal(subOpts.since, 12345);
|
||||
});
|
||||
});
|
||||
|
||||
describe("publishVideo", () => {
|
||||
it("should throw if not logged in", async () => {
|
||||
await assert.rejects(
|
||||
|
||||
Reference in new issue
Block a user