-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
46
packages/factory/src/operations/event/__tests__/note.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]], | ||
}), | ||
); | ||
}); | ||
}); |