2019-12-11 15:27:06 +00:00
|
|
|
import endPoints from '../endPoints';
|
|
|
|
|
|
|
|
describe('#sendMessage', () => {
|
|
|
|
it('returns correct payload', () => {
|
2020-01-01 17:00:43 +00:00
|
|
|
const spy = jest.spyOn(global, 'Date').mockImplementation(() => ({
|
|
|
|
toString: () => 'mock date',
|
|
|
|
}));
|
2019-12-11 15:27:06 +00:00
|
|
|
expect(endPoints.sendMessage('hello')).toEqual({
|
|
|
|
url: `/api/v1/widget/messages`,
|
|
|
|
params: {
|
|
|
|
message: {
|
|
|
|
content: 'hello',
|
2020-01-01 17:00:43 +00:00
|
|
|
referer_url: '',
|
|
|
|
timestamp: 'mock date',
|
2019-12-11 15:27:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
2020-01-01 17:00:43 +00:00
|
|
|
spy.mockRestore();
|
2019-12-11 15:27:06 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('#getConversation', () => {
|
|
|
|
it('returns correct payload', () => {
|
|
|
|
expect(endPoints.getConversation({ before: 123 })).toEqual({
|
|
|
|
url: `/api/v1/widget/messages`,
|
|
|
|
params: {
|
|
|
|
before: 123,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|