2021-07-14 04:50:06 +00:00
|
|
|
import csatReportsAPI from '../csatReports';
|
|
|
|
import ApiClient from '../ApiClient';
|
|
|
|
import describeWithAPIMock from './apiSpecHelper';
|
|
|
|
|
|
|
|
describe('#Reports API', () => {
|
|
|
|
it('creates correct instance', () => {
|
|
|
|
expect(csatReportsAPI).toBeInstanceOf(ApiClient);
|
|
|
|
expect(csatReportsAPI.apiVersion).toBe('/api/v1');
|
|
|
|
expect(csatReportsAPI).toHaveProperty('get');
|
|
|
|
expect(csatReportsAPI).toHaveProperty('getMetrics');
|
|
|
|
});
|
|
|
|
describeWithAPIMock('API calls', context => {
|
|
|
|
it('#get', () => {
|
2021-07-14 14:45:57 +00:00
|
|
|
csatReportsAPI.get({ page: 1, from: 1622485800, to: 1623695400 });
|
2021-07-14 04:50:06 +00:00
|
|
|
expect(context.axiosMock.get).toHaveBeenCalledWith(
|
|
|
|
'/api/v1/csat_survey_responses',
|
|
|
|
{
|
2021-07-14 14:45:57 +00:00
|
|
|
params: {
|
|
|
|
page: 1,
|
|
|
|
since: 1622485800,
|
|
|
|
until: 1623695400,
|
|
|
|
sort: '-created_at',
|
|
|
|
},
|
2021-07-14 04:50:06 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
it('#getMetrics', () => {
|
2021-07-14 14:45:57 +00:00
|
|
|
csatReportsAPI.getMetrics({ from: 1622485800, to: 1623695400 });
|
2021-07-14 04:50:06 +00:00
|
|
|
expect(context.axiosMock.get).toHaveBeenCalledWith(
|
2021-07-14 14:45:57 +00:00
|
|
|
'/api/v1/csat_survey_responses/metrics',
|
|
|
|
{
|
|
|
|
params: { since: 1622485800, until: 1623695400 },
|
|
|
|
}
|
2021-07-14 04:50:06 +00:00
|
|
|
);
|
|
|
|
});
|
2022-05-17 15:31:45 +00:00
|
|
|
it('#download', () => {
|
|
|
|
csatReportsAPI.download({
|
|
|
|
from: 1622485800,
|
|
|
|
to: 1623695400,
|
|
|
|
user_ids: 1,
|
|
|
|
});
|
|
|
|
expect(context.axiosMock.get).toHaveBeenCalledWith(
|
|
|
|
'/api/v1/csat_survey_responses/download',
|
|
|
|
{
|
|
|
|
params: {
|
|
|
|
since: 1622485800,
|
|
|
|
until: 1623695400,
|
|
|
|
user_ids: 1,
|
|
|
|
sort: '-created_at',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2021-07-14 04:50:06 +00:00
|
|
|
});
|
|
|
|
});
|