Skip to content

Commit 4e72cd7

Browse files
committed
style(chats): format chats action test (TM-214)
1 parent 1fbe383 commit 4e72cd7

1 file changed

Lines changed: 25 additions & 7 deletions

File tree

‎src/actions/tmgr/__tests__/chats.test.ts‎

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ jest.mock('../files', () => ({
1414
}));
1515

1616
import $axios from '@/plugins/axios';
17-
import { presignUpload, putToStorage } from '../files';
1817
import {
1918
createChannel,
2019
getMessage,
@@ -28,6 +27,7 @@ import {
2827
toggleReaction,
2928
uploadChatFile,
3029
} from '../chats';
30+
import { presignUpload, putToStorage } from '../files';
3131

3232
const ax = $axios as any;
3333
const ok = (data: any) => Promise.resolve({ data: { data } });
@@ -54,34 +54,49 @@ test('search sends q and optional limit', async () => {
5454

5555
test('creates a channel and opens a dm with snake_case bodies', async () => {
5656
ax.post.mockReturnValue(ok({ id: 3 }));
57-
await createChannel(7, { title: 'General', visibility: 'members', member_ids: [2] });
57+
await createChannel(7, {
58+
title: 'General',
59+
visibility: 'members',
60+
member_ids: [2],
61+
});
5862
expect(ax.post).toHaveBeenCalledWith('/workspaces/7/chats', {
5963
kind: 'channel',
6064
title: 'General',
6165
visibility: 'members',
6266
member_ids: [2],
6367
});
6468
await openDm(7, [2, 4]);
65-
expect(ax.post).toHaveBeenLastCalledWith('/workspaces/7/chats/dm', { user_ids: [2, 4] });
69+
expect(ax.post).toHaveBeenLastCalledWith('/workspaces/7/chats/dm', {
70+
user_ids: [2, 4],
71+
});
6672
});
6773

6874
test('message routes', async () => {
6975
ax.get.mockReturnValue(ok([]));
7076
await getMessages(3, { after_id: 10 });
71-
expect(ax.get).toHaveBeenCalledWith('/chats/3/messages', { params: { after_id: 10 } });
77+
expect(ax.get).toHaveBeenCalledWith('/chats/3/messages', {
78+
params: { after_id: 10 },
79+
});
7280
ax.get.mockReturnValue(ok({ id: 11 }));
7381
await expect(getMessage(3, 11)).resolves.toEqual({ id: 11 });
7482
expect(ax.get).toHaveBeenLastCalledWith('/chats/3/messages/11');
7583

7684
ax.post.mockReturnValue(ok({ id: 12 }));
77-
await sendMessage(3, { body: 'hi', mentions: [{ kind: 'user', id: 2 }], parent_message_id: 11 });
85+
await sendMessage(3, {
86+
body: 'hi',
87+
mentions: [{ kind: 'user', id: 2 }],
88+
parent_message_id: 11,
89+
});
7890
expect(ax.post).toHaveBeenCalledWith('/chats/3/messages', {
7991
body: 'hi',
8092
mentions: [{ kind: 'user', id: 2 }],
8193
parent_message_id: 11,
8294
});
8395
await toggleReaction(3, 12, '👍');
84-
expect(ax.post).toHaveBeenLastCalledWith('/chats/3/messages/12/reactions/toggle', { emoji: '👍' });
96+
expect(ax.post).toHaveBeenLastCalledWith(
97+
'/chats/3/messages/12/reactions/toggle',
98+
{ emoji: '👍' },
99+
);
85100
await markRead(3, 12);
86101
expect(ax.post).toHaveBeenLastCalledWith('/chats/3/read', { message_id: 12 });
87102
});
@@ -96,7 +111,10 @@ test('notifications send level and mute', async () => {
96111
});
97112

98113
test('uploads a file through presign and returns the attach payload', async () => {
99-
(presignUpload as jest.Mock).mockResolvedValue({ key: 'uploads/1/a.png', content_type: 'image/png' });
114+
(presignUpload as jest.Mock).mockResolvedValue({
115+
key: 'uploads/1/a.png',
116+
content_type: 'image/png',
117+
});
100118
const file = { name: 'a.png', size: 5, type: 'image/png' } as File;
101119
await expect(uploadChatFile(file)).resolves.toEqual({
102120
path: 'uploads/1/a.png',

0 commit comments

Comments
 (0)