Skip to content

Commit

Permalink
add a few more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hzrd149 committed Mar 1, 2025
1 parent ca2eb47 commit bf53581
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/smart-bats-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"applesauce-factory": patch
---

Add a few more tests
46 changes: 46 additions & 0 deletions packages/factory/src/operations/event/__tests__/note.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { describe, expect, it } from "vitest";
import { FakeUser } from "../../../__tests__/fixtures.js";
import { includeNoteThreadingNotifyTags } from "../note.js";

const user = new FakeUser();

describe("includeNoteThreadingNotifyTags", () => {
it('should copy all "p" tags', async () => {
const parent = user.note("what are you talking about?", { tags: [["p", "pubkey"]] });

expect(
await includeNoteThreadingNotifyTags(parent)({ kind: 1, content: "Im not sure", created_at: 0, tags: [] }, {}),
).toEqual(
expect.objectContaining({
tags: [
["p", "pubkey"],
["p", user.pubkey],
],
}),
);
});

it('should not copy "mention" "p" tags', async () => {
const parent = user.note("what are you talking about?", { tags: [["p", "pubkey", "", "mention"]] });

expect(
await includeNoteThreadingNotifyTags(parent)({ kind: 1, content: "Im not sure", created_at: 0, tags: [] }, {}),
).toEqual(
expect.objectContaining({
tags: [["p", user.pubkey]],
}),
);
});

it('should not add duplicate "p" tags', async () => {
const parent = user.note("what are you talking about?", { tags: [["p", user.pubkey]] });

expect(
await includeNoteThreadingNotifyTags(parent)({ kind: 1, content: "Im not sure", created_at: 0, tags: [] }, {}),
).toEqual(
expect.objectContaining({
tags: [["p", user.pubkey]],
}),
);
});
});

0 comments on commit bf53581

Please sign in to comment.