Don't include deleted or empty articles in list

This commit is contained in:
2024-10-28 13:56:36 +01:00
parent 5906655902
commit cea96e170d
4 changed files with 36 additions and 8 deletions

View File

@@ -1,17 +1,18 @@
import { beforeAll, describe, it } from "@std/testing/bdd";
import { expect } from "@std/expect";
import { NostrEvent as NEvent } from "@nostrify/nostrify";
import Article from "../../models/article.ts";
describe("Article", () => {
let articleEvent: NEvent;
let article: Article;
let deletedArticle: Article;
beforeAll(() => {
articleEvent = JSON.parse(
article = new Article(JSON.parse(
Deno.readTextFileSync("tests/fixtures/article-1.json"),
);
article = new Article(articleEvent);
));
deletedArticle = new Article(JSON.parse(
Deno.readTextFileSync("tests/fixtures/article-deleted.json"),
));
});
describe("#identifier", () => {
@@ -58,6 +59,13 @@ describe("Article", () => {
});
});
describe("#isDeleted", () => {
it("returns a boolean based on the 'deleted' tag", () => {
expect(article.isDeleted).toEqual(false);
expect(deletedArticle.isDeleted).toEqual(true);
});
});
describe("#naddr", () => {
it("returns a bech32 addressable event ID", () => {
expect(article.naddr).toMatch(