Skip to content

Commit 2e0618a

Browse files
committed
test: adjust reminder mock generator to type changes
1 parent 2403eb0 commit 2e0618a

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { nanoid } from 'nanoid';
2+
import type { ChannelConfigWithInfo, ChannelResponse } from 'stream-chat';
23

3-
export const generateChannel = (options = { channel: {} }) => {
4+
export const generateChannel = (
5+
options: {
6+
channel?: Partial<ChannelResponse>;
7+
config?: Partial<ChannelConfigWithInfo>;
8+
} = { channel: {}, config: {} },
9+
) => {
410
const { channel: optionsChannel, config, ...optionsBesidesChannel } = options;
511
const id = optionsChannel?.id ?? nanoid();
612
const type = optionsChannel?.type ?? 'messaging';
@@ -43,7 +49,7 @@ export const generateChannel = (options = { channel: {} }) => {
4349
uploads: true,
4450
url_enrichment: true,
4551
...config,
46-
},
52+
} as ChannelConfigWithInfo,
4753

4854
created_at: '2020-04-28T11:20:48.578147Z',
4955

@@ -56,11 +62,12 @@ export const generateChannel = (options = { channel: {} }) => {
5662
role: 'user',
5763
updated_at: '2020-04-28T11:21:08.357468Z',
5864
},
65+
disabled: false,
5966
frozen: false,
6067
id,
6168
type,
6269
updated_at: '2020-04-28T11:20:48.578147Z',
6370
...restOptionsChannel,
64-
},
71+
} as ChannelResponse,
6572
};
6673
};

src/mock-builders/generator/reminder.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type { ReminderResponse } from 'stream-chat';
2+
import { generateChannel } from './channel';
23

34
const baseData = {
4-
channel_cid: 'channel_cid',
5+
channel_cid: 'messaging:id',
56
message_id: 'message_id',
67
user_id: 'user_id',
78
} as const;
@@ -16,6 +17,7 @@ export const generateReminderResponse = ({
1617
const created_at = new Date().toISOString();
1718
const basePayload: ReminderResponse = {
1819
...baseData,
20+
channel: generateChannel({ channel: { cid: baseData.channel_cid } }).channel,
1921
created_at,
2022
message: { id: baseData.message_id, type: 'regular' },
2123
updated_at: created_at,

0 commit comments

Comments
 (0)