Skip to content

Commit

Permalink
wait for next update before validating the key value
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinse12 committed Nov 7, 2023
1 parent f8d681d commit 970aaee
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/node/subplebbit/edit.subplebbit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe(`subplebbit.edit`, async () => {
});

it(`Posts submitted to new sub address are shown in subplebbit.posts`, async () => {
await waitUntil(() => subplebbit.posts.pages.hot.comments.some((comment) => comment.cid === postToPublishAfterEdit.cid), {
await waitUntil(() => subplebbit?.posts?.pages?.hot?.comments?.some((comment) => comment.cid === postToPublishAfterEdit.cid), {
timeout: 200000
});
expect(Object.keys(subplebbit.posts.pageCids).sort()).to.deep.equal(Object.keys(POSTS_SORT_TYPES).sort());
Expand Down Expand Up @@ -205,8 +205,11 @@ describe(`Concurrency with subplebbit.edit`, async () => {
await updateStartedSubEventPromise;

expect(startedSubplebbit.title).to.equal(subplebbitTitle);
for (const [editKey, editValue] of Object.entries(editArgs))
for (const [editKey, editValue] of Object.entries(editArgs)){
if (stringify(startedSubplebbit[editKey]) !== stringify(editValue))
await new Promise(resolve => startedSubplebbit.once("update", resolve)); // Wait until the new props are included in the next update
expect(stringify(startedSubplebbit[editKey])).to.equal(stringify(editValue));
}

await startedSubplebbit.stop();

Expand Down

0 comments on commit 970aaee

Please sign in to comment.