mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-07 21:32:51 +00:00
Add ensureLoaded helper for subscriptions and align error UX
This commit is contained in:
1 parent
0fb1c36fe1
commit
078c8788b3
3 files changed
+70
-10
No files matched your search
@@ -540,6 +540,28 @@ test(
|
||||
},
|
||||
);
|
||||
|
||||
test("ensureLoaded memoizes concurrent loads", async () => {
|
||||
const SubscriptionsManager = subscriptions.constructor;
|
||||
const manager = new SubscriptionsManager();
|
||||
|
||||
let loadCount = 0;
|
||||
manager.loadSubscriptions = async () => {
|
||||
loadCount += 1;
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
manager.loaded = true;
|
||||
};
|
||||
|
||||
const actorHex = "f".repeat(64);
|
||||
|
||||
await Promise.all([
|
||||
manager.ensureLoaded(actorHex),
|
||||
manager.ensureLoaded(actorHex),
|
||||
]);
|
||||
|
||||
assert.equal(loadCount, 1, "loadSubscriptions should only run once");
|
||||
assert.equal(manager.loaded, true, "manager should be marked as loaded");
|
||||
});
|
||||
|
||||
test(
|
||||
"publishSubscriptionList succeeds with direct signer without requesting extension permissions",
|
||||
async () => {
|
||||
|
||||
Reference in new issue
Block a user