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("Article", () => { let articleEvent: NEvent; let article: Article; beforeAll(() => { articleEvent = JSON.parse( Deno.readTextFileSync("tests/fixtures/article-1.json"), ); article = new Article(articleEvent); }); describe("#identifier", () => { it("returns the content of the 'd' tag", () => { expect(article.identifier).toEqual("1726396758485"); }); }); describe("#isDraft", () => { it("is false when kind is 30023", () => { expect(article.isDraft).toBe(false); }); it("is true when kind is 30024", () => { article.event.kind = 30024; expect(article.isDraft).toBe(true); article.event.kind = 30023; }); }); 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(/