Feature: Send images from widget

This commit is contained in:
Nithin David Thomas
2020-03-30 12:15:06 +05:30
committed by GitHub
parent e56132c506
commit 6c4e1fdaac
16 changed files with 305 additions and 67 deletions

View File

@@ -42,4 +42,30 @@ describe('#actions', () => {
});
});
});
describe('#sendAttachment', () => {
it('sends correct mutations', () => {
const mockDate = new Date(1466424490000);
getUuid.mockImplementationOnce(() => '1111');
const spy = jest.spyOn(global, 'Date').mockImplementation(() => mockDate);
const thumbUrl = '';
const attachment = { thumbUrl };
actions.sendAttachment({ commit }, { attachment });
spy.mockRestore();
expect(commit).toBeCalledWith('pushMessageToConversation', {
id: '1111',
content: undefined,
status: 'in_progress',
created_at: 1466424490,
message_type: 0,
attachment: {
thumb_url: '',
data_url: '',
file_type: 'image',
status: 'in_progress',
},
});
});
});
});

View File

@@ -92,4 +92,29 @@ describe('#mutations', () => {
expect(state.uiFlags.allMessagesLoaded).toEqual(false);
});
});
describe('#setMessageStatus', () => {
it('Updates status of loading messages if payload is not empty', () => {
const state = {
conversations: {
rand_id_123: {
content: '',
id: 'rand_id_123',
message_type: 0,
status: 'in_progress',
},
},
};
const message = {
id: '1',
content: '',
status: 'sent',
};
mutations.setMessageStatus(state, { message, tempId: 'rand_id_123' });
expect(state.conversations).toEqual({
1: { id: '1', content: '', message_type: 0, status: 'sent' },
});
});
});
});

View File

@@ -30,7 +30,7 @@ describe('#findUndeliveredMessage', () => {
describe('#createTemporaryMessage', () => {
it('returns message object', () => {
const message = createTemporaryMessage('hello');
const message = createTemporaryMessage({ content: 'hello' });
expect(message.content).toBe('hello');
expect(message.status).toBe('in_progress');
});