| 68 | } |
| 69 | |
| 70 | function createMessage(raw: unknown, overrides: Partial<Message> = {}): Message { |
| 71 | const id = overrides.id ?? 'cmt-1'; |
| 72 | const text = overrides.text ?? 'Hello Kilo'; |
| 73 | const authorName = overrides.author?.fullName ?? 'Remon Doe'; |
| 74 | return { |
| 75 | id, |
| 76 | threadId: 'linear:iss-1', |
| 77 | text, |
| 78 | formatted: { type: 'root', children: [] }, |
| 79 | raw, |
| 80 | author: { |
| 81 | fullName: authorName, |
| 82 | isBot: false, |
| 83 | isMe: false, |
| 84 | userId: 'usr-1', |
| 85 | userName: 'Remon', |
| 86 | ...overrides.author, |
| 87 | }, |
| 88 | metadata: { |
| 89 | dateSent: new Date('2026-05-05T07:00:00Z'), |
| 90 | edited: false, |
| 91 | ...overrides.metadata, |
| 92 | }, |
| 93 | attachments: [], |
| 94 | links: [], |
| 95 | toJSON: () => ({ |
| 96 | _type: 'chat:Message', |
| 97 | id, |
| 98 | threadId: 'linear:iss-1', |
| 99 | text, |
| 100 | attachments: [], |
| 101 | author: { |
| 102 | fullName: authorName, |
| 103 | isBot: false, |
| 104 | isMe: false, |
| 105 | userId: 'usr-1', |
| 106 | userName: 'Remon', |
| 107 | }, |
| 108 | formatted: { type: 'root', children: [] }, |
| 109 | metadata: { dateSent: '2026-05-05T07:00:00.000Z', edited: false }, |
| 110 | raw, |
| 111 | }), |
| 112 | } as unknown as Message; |
| 113 | } |
| 114 | |
| 115 | type PostSpy = jest.Mock<Promise<void>, [{ markdown: string }]>; |
| 116 | |