import { beforeAll, describe, it } from "@std/testing/bdd"; import { expect } from "@std/expect"; import { NostrEvent as NEvent } from "@nostrify/nostrify"; import Profile from "../../models/profile.ts"; describe("Profile", () => { let profileEvent: NEvent; let profile: Profile; beforeAll(() => { profileEvent = JSON.parse( Deno.readTextFileSync("tests/fixtures/profile-1.json"), ); profile = new Profile(profileEvent); }); describe("constructor", () => { it("instantiates the username when given", () => { profile = new Profile(profileEvent, "raucao"); expect(profile.username).toEqual("raucao"); }); }); describe("#updatedAt", () => { it("returns the value of the profile event's 'created_at'", () => { expect(profile.updatedAt).toEqual(1728814592); }); }); describe("#name", () => { it("returns the profile's name when present", () => { expect(profile.name).toEqual("Râu Cao ⚡"); }); }); describe("#npub", () => { it("returns the bech32-encoded version of the pubkey", () => { expect(profile.npub).toEqual( "npub1raustrrh5gjwt03zdj8syn9vmt2dwsv9t467m8c3gua636uxu89svgdees", ); }); }); describe("#nprofile", () => { it("returns a bech32 profile ID", () => { expect(profile.nprofile).toMatch( /^nprofile1qyt8wumn8ghj7mn0wd68ytntdaek6mmn9ehhyecqyq0hjpvvw73zfed7yf/, ); }); }); });