|
1 | 1 | import type { IHttp, IModify, IPersistence, IRead } from '../../src/definition/accessors'; |
2 | 2 | import { HttpStatusCode } from '../../src/definition/accessors'; |
3 | | -import type { IMessage } from '../../src/definition/messages'; |
| 3 | +import type { IMessage, IMessageAttachment, IMessageRaw } from '../../src/definition/messages'; |
4 | 4 | import type { IRoom } from '../../src/definition/rooms'; |
5 | 5 | import { RoomType } from '../../src/definition/rooms'; |
6 | 6 | import type { ISetting } from '../../src/definition/settings'; |
@@ -128,6 +128,39 @@ export class TestInfastructureSetup { |
128 | 128 | } |
129 | 129 |
|
130 | 130 | const date = new Date(); |
| 131 | + |
| 132 | +const DEFAULT_ATTACHMENT = { |
| 133 | + color: '#00b2b2', |
| 134 | + collapsed: false, |
| 135 | + text: 'Just an attachment that is used for testing', |
| 136 | + timestampLink: 'https://google.com/', |
| 137 | + thumbnailUrl: 'https://avatars0.githubusercontent.com/u/850391?s=88&v=4', |
| 138 | + author: { |
| 139 | + name: 'Author Name', |
| 140 | + link: 'https://github.com/graywolf336', |
| 141 | + icon: 'https://avatars0.githubusercontent.com/u/850391?s=88&v=4', |
| 142 | + }, |
| 143 | + title: { |
| 144 | + value: 'Attachment Title', |
| 145 | + link: 'https://github.com/RocketChat', |
| 146 | + displayDownloadLink: false, |
| 147 | + }, |
| 148 | + imageUrl: 'https://rocket.chat/images/default/logo.svg', |
| 149 | + audioUrl: 'http://www.w3schools.com/tags/horse.mp3', |
| 150 | + videoUrl: 'http://www.w3schools.com/tags/movie.mp4', |
| 151 | + fields: [ |
| 152 | + { |
| 153 | + short: true, |
| 154 | + title: 'Test', |
| 155 | + value: 'Testing out something or other', |
| 156 | + }, |
| 157 | + { |
| 158 | + short: true, |
| 159 | + title: 'Another Test', |
| 160 | + value: '[Link](https://google.com/) something and this and that.', |
| 161 | + }, |
| 162 | + ], |
| 163 | +}; |
131 | 164 | export class TestData { |
132 | 165 | public static getDate(): Date { |
133 | 166 | return date; |
@@ -193,41 +226,42 @@ export class TestData { |
193 | 226 | emoji: ':see_no_evil:', |
194 | 227 | avatarUrl: 'https://avatars0.githubusercontent.com/u/850391?s=88&v=4', |
195 | 228 | alias: 'Testing Bot', |
196 | | - attachments: [ |
197 | | - { |
198 | | - collapsed: false, |
199 | | - color: '#00b2b2', |
200 | | - text: 'Just an attachment that is used for testing', |
201 | | - timestamp: new Date(), |
202 | | - timestampLink: 'https://google.com/', |
203 | | - thumbnailUrl: 'https://avatars0.githubusercontent.com/u/850391?s=88&v=4', |
204 | | - author: { |
205 | | - name: 'Author Name', |
206 | | - link: 'https://github.com/graywolf336', |
207 | | - icon: 'https://avatars0.githubusercontent.com/u/850391?s=88&v=4', |
208 | | - }, |
209 | | - title: { |
210 | | - value: 'Attachment Title', |
211 | | - link: 'https://github.com/RocketChat', |
212 | | - displayDownloadLink: false, |
213 | | - }, |
214 | | - imageUrl: 'https://rocket.chat/images/default/logo.svg', |
215 | | - audioUrl: 'http://www.w3schools.com/tags/horse.mp3', |
216 | | - videoUrl: 'http://www.w3schools.com/tags/movie.mp4', |
217 | | - fields: [ |
218 | | - { |
219 | | - short: true, |
220 | | - title: 'Test', |
221 | | - value: 'Testing out something or other', |
222 | | - }, |
223 | | - { |
224 | | - short: true, |
225 | | - title: 'Another Test', |
226 | | - value: '[Link](https://google.com/) something and this and that.', |
227 | | - }, |
228 | | - ], |
229 | | - }, |
230 | | - ], |
| 229 | + attachments: [this.createAttachment()], |
| 230 | + }; |
| 231 | + } |
| 232 | + |
| 233 | + public static getMessageRaw(id?: string, text?: string): IMessageRaw { |
| 234 | + const editorUser = TestData.getUser(); |
| 235 | + const senderUser = TestData.getUser(); |
| 236 | + |
| 237 | + return { |
| 238 | + id: id || '4bShvoOXqB', |
| 239 | + roomId: TestData.getRoom().id, |
| 240 | + sender: { |
| 241 | + _id: senderUser.id, |
| 242 | + username: senderUser.username, |
| 243 | + name: senderUser?.name, |
| 244 | + }, |
| 245 | + text: text || 'This is just a test, do not be alarmed', |
| 246 | + createdAt: date, |
| 247 | + updatedAt: new Date(), |
| 248 | + editor: { |
| 249 | + _id: editorUser.id, |
| 250 | + username: editorUser.username, |
| 251 | + }, |
| 252 | + editedAt: new Date(), |
| 253 | + emoji: ':see_no_evil:', |
| 254 | + avatarUrl: 'https://avatars0.githubusercontent.com/u/850391?s=88&v=4', |
| 255 | + alias: 'Testing Bot', |
| 256 | + attachments: [this.createAttachment()], |
| 257 | + }; |
| 258 | + } |
| 259 | + |
| 260 | + private static createAttachment(attachment?: IMessageAttachment): IMessageAttachment { |
| 261 | + attachment = attachment || DEFAULT_ATTACHMENT; |
| 262 | + return { |
| 263 | + timestamp: new Date(), |
| 264 | + ...attachment, |
231 | 265 | }; |
232 | 266 | } |
233 | 267 |
|
|
0 commit comments