MVP
This commit is contained in:
@@ -1,19 +1,16 @@
|
||||
import {
|
||||
beforeAll,
|
||||
beforeEach,
|
||||
describe,
|
||||
it,
|
||||
} from "@std/testing/bdd";
|
||||
import { beforeAll, describe, it } from "@std/testing/bdd";
|
||||
import { expect } from "@std/expect";
|
||||
import { NEvent } from "../../nostr.ts";
|
||||
import Article from "../../models/article.ts";
|
||||
|
||||
describe("User", () => {
|
||||
describe("Article", () => {
|
||||
let articleEvent: NEvent;
|
||||
let article: Article;
|
||||
|
||||
beforeAll(() => {
|
||||
articleEvent = JSON.parse(Deno.readTextFileSync("tests/fixtures/article-1.json"));
|
||||
articleEvent = JSON.parse(
|
||||
Deno.readTextFileSync("tests/fixtures/article-1.json"),
|
||||
);
|
||||
article = new Article(articleEvent);
|
||||
});
|
||||
|
||||
@@ -22,4 +19,44 @@ describe("User", () => {
|
||||
expect(article.identifier).toEqual("1726396758485");
|
||||
});
|
||||
});
|
||||
|
||||
describe("#title", () => {
|
||||
it("returns the content of the 'title' tag", () => {
|
||||
expect(article.title).toMatch(
|
||||
/How to confirm a stuck Lightning channel closing transaction/,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#summary", () => {
|
||||
it("returns the content of the 'summary' tag", () => {
|
||||
expect(article.summary).toEqual("");
|
||||
});
|
||||
});
|
||||
|
||||
describe("#publishedAt", () => {
|
||||
it("returns the value of the first 'published_at' tag", () => {
|
||||
expect(article.publishedAt).toEqual(1726402055);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#updatedAt", () => {
|
||||
it("returns the value of the first 'published_at' tag", () => {
|
||||
expect(article.updatedAt).toEqual(1729462158);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#html", () => {
|
||||
it("returns a rendered HTML version of the 'content'", () => {
|
||||
expect(article.html).toMatch(/<h2 id="the-solution">/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#naddr", () => {
|
||||
it("returns bech32 addressable event ID", () => {
|
||||
expect(article.naddr).toEqual(
|
||||
"naddr1qvzqqqr4gupzq8meqkx80g3yuklzymy0qfx2ekk56aqc2ht4ak03z3em4r4cdcwtqqxnzdejxcenjd3hx5urgwp4676hkz",
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
43
tests/models/profile_test.ts
Normal file
43
tests/models/profile_test.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
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",
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user