From 8a460d6bc57e4a7019d09b21e560fff4a8e4d146 Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Fri, 26 Apr 2024 16:23:10 -0300 Subject: [PATCH] test: create rough tests for UserStore --- src/storages/UserStore.test.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/storages/UserStore.test.ts diff --git a/src/storages/UserStore.test.ts b/src/storages/UserStore.test.ts new file mode 100644 index 0000000..85cca61 --- /dev/null +++ b/src/storages/UserStore.test.ts @@ -0,0 +1,25 @@ +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' }; +import { NCache } from 'jsr:@nostrify/nostrify'; +import { UserStore } from '@/storages/UserStore.ts'; +import { assertEquals } from '@/deps-test.ts'; + +Deno.test('query events of users that are not blocked', async () => { + const userBlackCopy = structuredClone(userBlack); + const userMeCopy = structuredClone(userMe); + const blockEventCopy = structuredClone(blockEvent); + const event1authorUserMeCopy = structuredClone(event1authorUserMe); + + const db = new NCache({ max: 100 }); + + 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 }), []); +});