View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/671 Closes #726 Approved-by: dakkar <dakkar@thenautilus.net> Approved-by: Marie <github@yuugi.dev>
This commit is contained in:
commit
de9b99c937
20 changed files with 478 additions and 104 deletions
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { isQuote, isRenote } from '@/misc/is-renote.js';
|
||||
import { isPureRenote, isQuote, isRenote } from '@/misc/is-renote.js';
|
||||
import { MiNote } from '@/models/Note.js';
|
||||
|
||||
const base: MiNote = {
|
||||
|
|
@ -86,4 +86,24 @@ describe('misc:is-renote', () => {
|
|||
expect(isRenote(note)).toBe(true);
|
||||
expect(isQuote(note as any)).toBe(true);
|
||||
});
|
||||
|
||||
describe('isPureRenote', () => {
|
||||
it('should return true when note is pure renote', () => {
|
||||
const note = new MiNote({ renoteId: 'abc123', fileIds: [] });
|
||||
const result = isPureRenote(note);
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return false when note is quote', () => {
|
||||
const note = new MiNote({ renoteId: 'abc123', text: 'text', fileIds: [] });
|
||||
const result = isPureRenote(note);
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return false when note is not renote', () => {
|
||||
const note = new MiNote({ renoteId: null, fileIds: [] });
|
||||
const result = isPureRenote(note);
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
66
packages/backend/test/unit/models/LatestNote.ts
Normal file
66
packages/backend/test/unit/models/LatestNote.ts
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import { SkLatestNote } from '@/models/LatestNote.js';
|
||||
import { MiNote } from '@/models/Note.js';
|
||||
|
||||
describe(SkLatestNote, () => {
|
||||
describe('keyFor', () => {
|
||||
it('should include userId', () => {
|
||||
const note = new MiNote({ userId: 'abc123', fileIds: [] });
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
expect(key.userId).toBe(note.userId);
|
||||
});
|
||||
|
||||
it('should include isPublic when is public', () => {
|
||||
const note = new MiNote({ visibility: 'public', fileIds: [] });
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
expect(key.isPublic).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should include isPublic when is home-only', () => {
|
||||
const note = new MiNote({ visibility: 'home', fileIds: [] });
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
expect(key.isPublic).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should include isPublic when is followers-only', () => {
|
||||
const note = new MiNote({ visibility: 'followers', fileIds: [] });
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
expect(key.isPublic).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should include isPublic when is specified', () => {
|
||||
const note = new MiNote({ visibility: 'specified', fileIds: [] });
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
expect(key.isPublic).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should include isReply when is reply', () => {
|
||||
const note = new MiNote({ replyId: 'abc123', fileIds: [] });
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
expect(key.isReply).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should include isReply when is not reply', () => {
|
||||
const note = new MiNote({ replyId: null, fileIds: [] });
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
expect(key.isReply).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should include isQuote when is quote', () => {
|
||||
const note = new MiNote({ renoteId: 'abc123', text: 'text', fileIds: [] });
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
expect(key.isQuote).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should include isQuote when is reblog', () => {
|
||||
const note = new MiNote({ renoteId: 'abc123', fileIds: [] });
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
expect(key.isQuote).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should include isQuote when is neither quote nor reblog', () => {
|
||||
const note = new MiNote({ renoteId: null, fileIds: [] });
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
expect(key.isQuote).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue