Signed-off-by: Jay Gabriels <jgabriels30@gmail.com>
This commit is contained in:
Jay Gabriels
2022-01-21 12:29:10 -08:00
parent 5a459626bc
commit fb247b39d8
@@ -92,6 +92,54 @@ describe('Incidents', () => {
expect(getAllByTitle('View in PagerDuty').length).toEqual(2);
});
it('Does not render a pagerduty link when html_url is not present in response', async () => {
mockPagerDutyApi.getChangeEventsByServiceId = jest
.fn()
.mockImplementationOnce(
async () =>
[
{
id: 'id1',
source: 'changeSource1',
links: [
{
href: 'www.externalLink1.com',
text: 'link1',
},
],
summary: 'summary of event',
timestamp: '2020-07-17T08:42:58.315+0000',
},
{
id: 'id2',
source: 'changeSource1',
html_url: 'www.pdlink.com/link',
links: [
{
href: 'www.externalLink1.com',
text: 'link1',
},
],
summary: 'sum of EVENT',
timestamp: '2020-07-18T08:42:58.315+0000',
},
] as ChangeEvent[],
);
const { getByText, getAllByTitle, queryByTestId } = render(
wrapInTestApp(
<ApiProvider apis={apis}>
<ChangeEvents serviceId="abc" refreshEvents={false} />
</ApiProvider>,
),
);
await waitFor(() => !queryByTestId('progress'));
expect(getByText('summary of event')).toBeInTheDocument();
expect(getByText('sum of EVENT')).toBeInTheDocument();
// assert links, mailto and hrefs, date calculation
expect(getAllByTitle('View in PagerDuty').length).toEqual(1);
});
it('Handle errors', async () => {
mockPagerDutyApi.getChangeEventsByServiceId = jest
.fn()