Skip to content

Commit 32d0f31

Browse files
committed
test: remove MessageStatus tests for legacy styles
1 parent e9cf42f commit 32d0f31

File tree

2 files changed

+161
-320
lines changed

2 files changed

+161
-320
lines changed

src/components/Message/__tests__/MessageStatus.test.js

Lines changed: 156 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -56,184 +56,182 @@ const renderComponent = ({ chatCtx, componentCtx, messageCtx, props } = {}) =>
5656
);
5757

5858
describe('MessageStatus', () => {
59-
describe.each(['1', '2'])('theme v%s', (themeVersion) => {
60-
it('renders nothing for not own messages', async () => {
61-
const client = await getTestClientWithUser(user);
62-
const { container } = renderComponent({
63-
chatCtx: { client, themeVersion },
64-
messageCtx: { isMyMessage: () => false, message: foreignMsg },
65-
});
66-
expect(container).toBeEmptyDOMElement();
59+
it('renders nothing for not own messages', async () => {
60+
const client = await getTestClientWithUser(user);
61+
const { container } = renderComponent({
62+
chatCtx: { client },
63+
messageCtx: { isMyMessage: () => false, message: foreignMsg },
6764
});
68-
it('renders nothing for error messages', async () => {
69-
const client = await getTestClientWithUser(user);
70-
const { container } = renderComponent({
71-
chatCtx: { client, themeVersion },
72-
messageCtx: { message: errorMsg },
73-
});
74-
expect(container).toBeEmptyDOMElement();
65+
expect(container).toBeEmptyDOMElement();
66+
});
67+
it('renders nothing for error messages', async () => {
68+
const client = await getTestClientWithUser(user);
69+
const { container } = renderComponent({
70+
chatCtx: { client },
71+
messageCtx: { message: errorMsg },
7572
});
73+
expect(container).toBeEmptyDOMElement();
74+
});
7675

77-
it('renders default sending UI for the last message', async () => {
78-
const client = await getTestClientWithUser(user);
79-
renderComponent({
80-
chatCtx: { client, themeVersion },
81-
messageCtx: { lastReceivedId: sendingMsg.id, message: sendingMsg },
82-
});
83-
expect(screen.getByTestId(MESSAGE_STATUS_SENDING_TEST_ID)).toMatchSnapshot();
76+
it('renders default sending UI for the last message', async () => {
77+
const client = await getTestClientWithUser(user);
78+
renderComponent({
79+
chatCtx: { client },
80+
messageCtx: { lastReceivedId: sendingMsg.id, message: sendingMsg },
8481
});
82+
expect(screen.getByTestId(MESSAGE_STATUS_SENDING_TEST_ID)).toMatchSnapshot();
83+
});
8584

86-
it('renders custom sending UI for the last message', async () => {
87-
const text = 'CustomMessageSendingStatus';
88-
const MessageSendingStatus = () => <div>{text}</div>;
89-
const client = await getTestClientWithUser(user);
90-
renderComponent({
91-
chatCtx: { client, themeVersion },
92-
messageCtx: { lastReceivedId: sendingMsg.id, message: sendingMsg },
93-
props: { MessageSendingStatus },
94-
});
95-
expect(screen.getByText(text)).toBeInTheDocument();
85+
it('renders custom sending UI for the last message', async () => {
86+
const text = 'CustomMessageSendingStatus';
87+
const MessageSendingStatus = () => <div>{text}</div>;
88+
const client = await getTestClientWithUser(user);
89+
renderComponent({
90+
chatCtx: { client },
91+
messageCtx: { lastReceivedId: sendingMsg.id, message: sendingMsg },
92+
props: { MessageSendingStatus },
9693
});
94+
expect(screen.getByText(text)).toBeInTheDocument();
95+
});
9796

98-
it('renders default sending UI for not the last message', async () => {
99-
const client = await getTestClientWithUser(user);
100-
renderComponent({ chatCtx: { client, themeVersion }, messageCtx: { message: sendingMsg } });
101-
expect(screen.getByTestId(MESSAGE_STATUS_SENDING_TEST_ID)).toMatchSnapshot();
102-
});
97+
it('renders default sending UI for not the last message', async () => {
98+
const client = await getTestClientWithUser(user);
99+
renderComponent({ chatCtx: { client }, messageCtx: { message: sendingMsg } });
100+
expect(screen.getByTestId(MESSAGE_STATUS_SENDING_TEST_ID)).toMatchSnapshot();
101+
});
103102

104-
it('renders custom sending UI for not the last message', async () => {
105-
const text = 'CustomMessageSendingStatus';
106-
const MessageSendingStatus = () => <div>{text}</div>;
107-
const client = await getTestClientWithUser(user);
108-
renderComponent({
109-
chatCtx: { client, themeVersion },
110-
messageCtx: { message: sendingMsg },
111-
props: { MessageSendingStatus },
112-
});
113-
expect(screen.getByText(text)).toBeInTheDocument();
103+
it('renders custom sending UI for not the last message', async () => {
104+
const text = 'CustomMessageSendingStatus';
105+
const MessageSendingStatus = () => <div>{text}</div>;
106+
const client = await getTestClientWithUser(user);
107+
renderComponent({
108+
chatCtx: { client },
109+
messageCtx: { message: sendingMsg },
110+
props: { MessageSendingStatus },
114111
});
112+
expect(screen.getByText(text)).toBeInTheDocument();
113+
});
115114

116-
// here
117-
it('renders default delivered UI for the last message', async () => {
118-
const client = await getTestClientWithUser(user);
119-
renderComponent({
120-
chatCtx: { client, themeVersion },
121-
messageCtx: { lastReceivedId: deliveredMsg.id, message: deliveredMsg },
122-
});
123-
expect(screen.getByTestId(MESSAGE_STATUS_DELIVERED_TEST_ID)).toMatchSnapshot();
115+
// here
116+
it('renders default delivered UI for the last message', async () => {
117+
const client = await getTestClientWithUser(user);
118+
renderComponent({
119+
chatCtx: { client },
120+
messageCtx: { lastReceivedId: deliveredMsg.id, message: deliveredMsg },
124121
});
122+
expect(screen.getByTestId(MESSAGE_STATUS_DELIVERED_TEST_ID)).toMatchSnapshot();
123+
});
125124

126-
it('renders custom delivered UI for the last message', async () => {
127-
const text = 'CustomMessageDeliveredStatus';
128-
const MessageDeliveredStatus = () => <div>{text}</div>;
129-
const client = await getTestClientWithUser(user);
130-
renderComponent({
131-
chatCtx: { client, themeVersion },
132-
messageCtx: { lastReceivedId: deliveredMsg.id, message: deliveredMsg },
133-
props: { MessageDeliveredStatus },
134-
});
135-
expect(screen.getByText(text)).toBeInTheDocument();
125+
it('renders custom delivered UI for the last message', async () => {
126+
const text = 'CustomMessageDeliveredStatus';
127+
const MessageDeliveredStatus = () => <div>{text}</div>;
128+
const client = await getTestClientWithUser(user);
129+
renderComponent({
130+
chatCtx: { client },
131+
messageCtx: { lastReceivedId: deliveredMsg.id, message: deliveredMsg },
132+
props: { MessageDeliveredStatus },
136133
});
134+
expect(screen.getByText(text)).toBeInTheDocument();
135+
});
137136

138-
it('renders empty container without default delivered UI for not the last message', async () => {
139-
const client = await getTestClientWithUser(user);
140-
const { container } = renderComponent({
141-
chatCtx: { client, themeVersion },
142-
messageCtx: { message: deliveredMsg },
143-
});
144-
expect(container.children[0]).toHaveClass(rootClassName);
145-
expect(container.children[0]).toBeEmptyDOMElement();
137+
it('renders empty container without default delivered UI for not the last message', async () => {
138+
const client = await getTestClientWithUser(user);
139+
const { container } = renderComponent({
140+
chatCtx: { client },
141+
messageCtx: { message: deliveredMsg },
146142
});
143+
expect(container.children[0]).toHaveClass(rootClassName);
144+
expect(container.children[0]).toBeEmptyDOMElement();
145+
});
147146

148-
it('renders empty container without custom delivered UI for not the last message', async () => {
149-
const text = 'CustomMessageDeliveredStatus';
150-
const MessageDeliveredStatus = () => <div>{text}</div>;
151-
const client = await getTestClientWithUser(user);
152-
const { container } = renderComponent({
153-
chatCtx: { client, themeVersion },
154-
messageCtx: { message: deliveredMsg },
155-
props: { MessageDeliveredStatus },
156-
});
157-
expect(container.children[0]).toHaveClass(rootClassName);
158-
expect(container.children[0]).toBeEmptyDOMElement();
159-
});
147+
it('renders empty container without custom delivered UI for not the last message', async () => {
148+
const text = 'CustomMessageDeliveredStatus';
149+
const MessageDeliveredStatus = () => <div>{text}</div>;
150+
const client = await getTestClientWithUser(user);
151+
const { container } = renderComponent({
152+
chatCtx: { client },
153+
messageCtx: { message: deliveredMsg },
154+
props: { MessageDeliveredStatus },
155+
});
156+
expect(container.children[0]).toHaveClass(rootClassName);
157+
expect(container.children[0]).toBeEmptyDOMElement();
158+
});
160159

161-
it('renders default read UI for the last message', async () => {
162-
const client = await getTestClientWithUser(user);
163-
renderComponent({
164-
chatCtx: { client, themeVersion },
165-
messageCtx: {
166-
lastReceivedId: deliveredMsg.id,
167-
message: deliveredMsg,
168-
readBy: readByOthers,
169-
},
170-
});
171-
expect(screen.getByTestId(MESSAGE_STATUS_READ_TEST_ID)).toMatchSnapshot();
172-
});
173-
it('renders custom read UI for the last message', async () => {
174-
const text = 'CustomMessageReadStatus';
175-
const MessageReadStatus = () => <div>{text}</div>;
176-
const client = await getTestClientWithUser(user);
177-
renderComponent({
178-
chatCtx: { client, themeVersion },
179-
messageCtx: {
180-
lastReceivedId: deliveredMsg.id,
181-
message: deliveredMsg,
182-
readBy: readByOthers,
183-
},
184-
props: { MessageReadStatus },
185-
});
186-
expect(screen.getByText(text)).toBeInTheDocument();
187-
});
188-
it('renders empty container without default read UI for not the last message', async () => {
189-
const client = await getTestClientWithUser(user);
190-
const { container } = renderComponent({
191-
chatCtx: { client, themeVersion },
192-
messageCtx: { message: deliveredMsg },
193-
});
194-
expect(container.children[0]).toHaveClass(rootClassName);
195-
expect(container.children[0]).toBeEmptyDOMElement();
196-
});
160+
it('renders default read UI for the last message', async () => {
161+
const client = await getTestClientWithUser(user);
162+
renderComponent({
163+
chatCtx: { client },
164+
messageCtx: {
165+
lastReceivedId: deliveredMsg.id,
166+
message: deliveredMsg,
167+
readBy: readByOthers,
168+
},
169+
});
170+
expect(screen.getByTestId(MESSAGE_STATUS_READ_TEST_ID)).toMatchSnapshot();
171+
});
172+
it('renders custom read UI for the last message', async () => {
173+
const text = 'CustomMessageReadStatus';
174+
const MessageReadStatus = () => <div>{text}</div>;
175+
const client = await getTestClientWithUser(user);
176+
renderComponent({
177+
chatCtx: { client },
178+
messageCtx: {
179+
lastReceivedId: deliveredMsg.id,
180+
message: deliveredMsg,
181+
readBy: readByOthers,
182+
},
183+
props: { MessageReadStatus },
184+
});
185+
expect(screen.getByText(text)).toBeInTheDocument();
186+
});
187+
it('renders empty container without default read UI for not the last message', async () => {
188+
const client = await getTestClientWithUser(user);
189+
const { container } = renderComponent({
190+
chatCtx: { client },
191+
messageCtx: { message: deliveredMsg },
192+
});
193+
expect(container.children[0]).toHaveClass(rootClassName);
194+
expect(container.children[0]).toBeEmptyDOMElement();
195+
});
197196

198-
it('renders empty container without custom read UI for not the last message', async () => {
199-
const text = 'CustomMessageReadStatus';
200-
const MessageReadStatus = () => <div>{text}</div>;
201-
const client = await getTestClientWithUser(user);
202-
const { container } = renderComponent({
203-
chatCtx: { client, themeVersion },
204-
messageCtx: { message: deliveredMsg },
205-
props: { MessageReadStatus },
206-
});
207-
expect(container.children[0]).toHaveClass(rootClassName);
208-
expect(container.children[0]).toBeEmptyDOMElement();
209-
});
197+
it('renders empty container without custom read UI for not the last message', async () => {
198+
const text = 'CustomMessageReadStatus';
199+
const MessageReadStatus = () => <div>{text}</div>;
200+
const client = await getTestClientWithUser(user);
201+
const { container } = renderComponent({
202+
chatCtx: { client },
203+
messageCtx: { message: deliveredMsg },
204+
props: { MessageReadStatus },
205+
});
206+
expect(container.children[0]).toHaveClass(rootClassName);
207+
expect(container.children[0]).toBeEmptyDOMElement();
208+
});
210209

211-
it('renders custom Avatar in default read status', async () => {
212-
const text = 'CustomAvatar';
213-
const Avatar = () => <div>{text}</div>;
214-
const client = await getTestClientWithUser(user);
215-
renderComponent({
216-
chatCtx: { client, themeVersion },
217-
messageCtx: {
218-
lastReceivedId: deliveredMsg.id,
219-
message: deliveredMsg,
220-
readBy: readByOthers,
221-
},
222-
props: { Avatar },
223-
});
224-
expect(screen.getByText(text)).toBeInTheDocument();
225-
expect(screen.queryByTestId('avatar')).not.toBeInTheDocument();
226-
});
210+
it('renders custom Avatar in default read status', async () => {
211+
const text = 'CustomAvatar';
212+
const Avatar = () => <div>{text}</div>;
213+
const client = await getTestClientWithUser(user);
214+
renderComponent({
215+
chatCtx: { client },
216+
messageCtx: {
217+
lastReceivedId: deliveredMsg.id,
218+
message: deliveredMsg,
219+
readBy: readByOthers,
220+
},
221+
props: { Avatar },
222+
});
223+
expect(screen.getByText(text)).toBeInTheDocument();
224+
expect(screen.queryByTestId('avatar')).not.toBeInTheDocument();
225+
});
227226

228-
it('reflects messageType prop in root class', async () => {
229-
const client = await getTestClientWithUser(user);
230-
const { container } = renderComponent({
231-
chatCtx: { client, themeVersion },
232-
messageCtx: { message: deliveredMsg },
233-
props: { messageType: 'XXX' },
234-
});
235-
expect(container.children[0]).not.toHaveClass('str-chat__message-simple-status');
236-
expect(container.children[0]).toHaveClass('str-chat__message-XXX-status');
227+
it('reflects messageType prop in root class', async () => {
228+
const client = await getTestClientWithUser(user);
229+
const { container } = renderComponent({
230+
chatCtx: { client },
231+
messageCtx: { message: deliveredMsg },
232+
props: { messageType: 'XXX' },
237233
});
234+
expect(container.children[0]).not.toHaveClass('str-chat__message-simple-status');
235+
expect(container.children[0]).toHaveClass('str-chat__message-XXX-status');
238236
});
239237
});

0 commit comments

Comments
 (0)