blowater/UI/search.test.tsx

27 lines
871 B
TypeScript
Raw Normal View History

2023-06-30 14:05:57 +00:00
/** @jsx h */
import { h, render } from "https://esm.sh/preact@10.17.1";
import { Search } from "./search.tsx";
import { testEventBus, testEventsAdapter } from "./_setup.test.ts";
import { Datebase_View } from "../database.ts";
import { InMemoryAccountContext, NostrKind } from "../lib/nostr-ts/nostr.ts";
import { PrivateKey } from "../lib/nostr-ts/key.ts";
import { prepareNormalNostrEvent } from "../lib/nostr-ts/event.ts";
2023-06-30 14:05:57 +00:00
const ctx = InMemoryAccountContext.New(PrivateKey.Generate());
await testEventsAdapter.put(await prepareNormalNostrEvent(ctx, NostrKind.META_DATA, [], `{"name":"mike"}`));
const db = await Datebase_View.New(testEventsAdapter, ctx);
2023-06-30 14:05:57 +00:00
render(
<Search
placeholder="search for data"
emit={testEventBus.emit}
db={db}
2023-06-30 14:05:57 +00:00
/>,
document.body,
);
for await (const e of testEventBus.onChange()) {
console.log(e);
2023-06-30 14:05:57 +00:00
}