mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
41 lines
1.6 KiB
TypeScript
41 lines
1.6 KiB
TypeScript
import { MockRelay } from '@nostrify/nostrify/test';
|
|
|
|
import { assertEquals } from '@std/assert';
|
|
import { UserStore } from '@/storages/UserStore.ts';
|
|
|
|
import userBlack from '~/fixtures/events/kind-0-black.json' with { type: 'json' };
|
|
import userMe from '~/fixtures/events/event-0-makes-repost-with-quote-repost.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' };
|
|
|
|
Deno.test('query events of users that are not muted', async () => {
|
|
const userBlackCopy = structuredClone(userBlack);
|
|
const userMeCopy = structuredClone(userMe);
|
|
const blockEventCopy = structuredClone(blockEvent);
|
|
const event1authorUserMeCopy = structuredClone(event1authorUserMe);
|
|
|
|
const db = new MockRelay();
|
|
|
|
const store = new UserStore(userBlackCopy.pubkey, db);
|
|
|
|
await store.event(blockEventCopy);
|
|
await store.event(userBlackCopy);
|
|
await store.event(userMeCopy);
|
|
await store.event(event1authorUserMeCopy);
|
|
|
|
assertEquals(await store.query([{ kinds: [1] }], { limit: 1 }), []);
|
|
});
|
|
|
|
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.query([{ kinds: [0], authors: [userMeCopy.pubkey] }], { limit: 1 }), [userMeCopy]);
|
|
});
|