test: UserStore with 100.00% code coverage

This commit is contained in:
P. Reis 2024-05-10 10:35:04 -03:00
parent 0c0465f131
commit 26dd4606ed
1 changed files with 16 additions and 1 deletions

View File

@ -8,7 +8,7 @@ import userMe from '~/fixtures/events/event-0-makes-repost-with-quote-repost.jso
import blockEvent from '~/fixtures/events/kind-10000-black-blocks-user-me.json' with { type: 'json' }; import blockEvent from '~/fixtures/events/kind-10000-black-blocks-user-me.json' with { type: 'json' };
import event1authorUserMe from '~/fixtures/events/event-1-quote-repost-will-be-reposted.json' with { type: 'json' }; import event1authorUserMe from '~/fixtures/events/event-1-quote-repost-will-be-reposted.json' with { type: 'json' };
Deno.test('query events of users that are not blocked', async () => { Deno.test('query events of users that are not muted', async () => {
const userBlackCopy = structuredClone(userBlack); const userBlackCopy = structuredClone(userBlack);
const userMeCopy = structuredClone(userMe); const userMeCopy = structuredClone(userMe);
const blockEventCopy = structuredClone(blockEvent); const blockEventCopy = structuredClone(blockEvent);
@ -24,4 +24,19 @@ Deno.test('query events of users that are not blocked', async () => {
await store.event(event1authorUserMeCopy); await store.event(event1authorUserMeCopy);
assertEquals(await store.query([{ kinds: [1] }], { limit: 1 }), []); assertEquals(await store.query([{ kinds: [1] }], { limit: 1 }), []);
assertEquals(await store.isMuted(userMeCopy.pubkey), true);
});
Deno.test('user never muted anyone', async () => {
const userBlackCopy = structuredClone(userBlack);
const userMeCopy = structuredClone(userMe);
const db = new MockRelay();
const store = new UserStore(userBlackCopy.pubkey, db);
await store.event(userBlackCopy);
await store.event(userMeCopy);
assertEquals(await store.isMuted(userMeCopy.pubkey), false);
}); });