44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { beforeAll, describe, it } from "@std/testing/bdd";
|
|
import { expect } from "@std/expect";
|
|
import { NEvent } from "../../nostr.ts";
|
|
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",
|
|
);
|
|
});
|
|
});
|
|
});
|