| 119 | } |
| 120 | |
| 121 | function createThread( |
| 122 | post: PostSpy = jest.fn<Promise<void>, [{ markdown: string }]>(async () => undefined), |
| 123 | overrides: { threadMessages?: Message[]; id?: string } = {} |
| 124 | ): Thread { |
| 125 | const id = overrides.id ?? 'linear:iss-1'; |
| 126 | return { |
| 127 | id, |
| 128 | adapter: { name: 'linear' }, |
| 129 | isDM: false, |
| 130 | channel: { |
| 131 | fetchMetadata: async () => null, |
| 132 | }, |
| 133 | get messages() { |
| 134 | return asAsyncIterable(overrides.threadMessages ?? []); |
| 135 | }, |
| 136 | post, |
| 137 | toJSON: () => ({ |
| 138 | _type: 'chat:Thread', |
| 139 | adapterName: 'linear', |
| 140 | channelId: id, |
| 141 | id, |
| 142 | isDM: false, |
| 143 | }), |
| 144 | } as unknown as Thread; |
| 145 | } |
| 146 | |
| 147 | function createPlatformIntegration( |
| 148 | overrides: Partial<PlatformIntegration> = {} |