Create contact-list.test.tsx

This commit is contained in:
BlowaterNostr 2023-09-13 11:31:44 +00:00
parent 60d1155f81
commit 0ab4fc0861

43
UI/contact-list.test.tsx Normal file
View File

@ -0,0 +1,43 @@
/** @jsx h */
import { h, render } from "https://esm.sh/preact@10.17.1";
import { ContactList } from "./contact-list.tsx";
import { fail } from "https://deno.land/std@0.176.0/testing/asserts.ts";
import { Database_Contextual_View } from "../database.ts";
import { PrivateKey } from "../lib/nostr-ts/key.ts";
import { InMemoryAccountContext } from "../lib/nostr-ts/nostr.ts";
import { testEventBus, testEventsAdapter } from "./_setup.test.ts";
import { ConnectionPool } from "../lib/nostr-ts/relay.ts";
import { initialModel } from "./app_model.ts";
import { AllUsersInformation } from "./contact-list.ts";
import { ProfilesSyncer } from "../features/profile.ts";
const ctx = InMemoryAccountContext.New(PrivateKey.Generate());
const database = await Database_Contextual_View.New(testEventsAdapter, ctx);
if (database instanceof Error) {
fail(database.message);
}
const allUserInfo = new AllUsersInformation(ctx);
// allUserInfo.addEvents([e]);
const pool = new ConnectionPool();
const model = initialModel();
const profileSyncer = new ProfilesSyncer(database, pool);
render(
<ContactList
database={database}
emit={testEventBus.emit}
userInfoMap={allUserInfo.userInfos}
currentSelected={ctx.publicKey}
editors={model.editors}
hasNewMessages={new Set()}
myAccountContext={ctx}
search={model.dm.search}
selectedContactGroup={model.dm.selectedContactGroup}
profileSyncer={profileSyncer}
/>,
document.body,
);
for await (const e of testEventBus.onChange()) {
console.log(e);
}