fix: Set cc, bcc default to empty string if unavailable (#3387)

This commit is contained in:
Pranav Raj S
2021-11-15 21:05:24 +05:30
committed by GitHub
parent acb06e7df6
commit 809509404b
2 changed files with 8 additions and 4 deletions

View File

@@ -8,8 +8,8 @@ export const buildCreatePayload = ({
contentAttributes,
echoId,
file,
ccEmails,
bccEmails,
ccEmails = '',
bccEmails = '',
}) => {
let payload;
if (file) {
@@ -47,8 +47,8 @@ class MessageApi extends ApiClient {
contentAttributes,
echo_id: echoId,
file,
ccEmails,
bccEmails,
ccEmails = '',
bccEmails = '',
}) {
return axios({
method: 'post',

View File

@@ -35,12 +35,14 @@ describe('#ConversationAPI', () => {
message: 'test content',
echoId: 12,
isPrivate: true,
file: new Blob(['test-content'], { type: 'application/pdf' }),
});
expect(formPayload).toBeInstanceOf(FormData);
expect(formPayload.get('content')).toEqual('test content');
expect(formPayload.get('echo_id')).toEqual('12');
expect(formPayload.get('private')).toEqual('true');
expect(formPayload.get('cc_emails')).toEqual('');
});
it('builds object payload if file is not available', () => {
@@ -56,6 +58,8 @@ describe('#ConversationAPI', () => {
private: false,
echo_id: 12,
content_attributes: { in_reply_to: 12 },
bcc_emails: '',
cc_emails: '',
});
});
});