mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 13:49:50 -04:00
Fix jest
This commit is contained in:
@@ -40,7 +40,7 @@ beforeAll(done => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="aria-live-account" class="usa-sr-only" aria-live="polite"></div>
|
<div id="aria-live-account" class="usa-sr-only" aria-live="polite"></div>
|
||||||
<div id="activityContainer" data-currentUserName="Test User"></div>
|
<div id="activityContainer" data-currentUserName="Test User" data-currentServiceId="12345"></div>
|
||||||
|
|
||||||
<div id="aria-live-account" class="usa-sr-only" aria-live="polite"></div>
|
<div id="aria-live-account" class="usa-sr-only" aria-live="polite"></div>
|
||||||
`;
|
`;
|
||||||
@@ -186,6 +186,9 @@ test('Fetches data and creates chart and table correctly', async () => {
|
|||||||
'2024-07-06': { sms: { delivered: 100, failed: 4, pending: 5 } },
|
'2024-07-06': { sms: { delivered: 100, failed: 4, pending: 5 } },
|
||||||
'2024-07-07': { sms: { delivered: 110, failed: 2, pending: 3 } },
|
'2024-07-07': { sms: { delivered: 110, failed: 2, pending: 3 } },
|
||||||
};
|
};
|
||||||
|
const tableContainer = document.getElementById('activityContainer');
|
||||||
|
const currentServiceId = tableContainer.getAttribute('data-currentServiceId');
|
||||||
|
|
||||||
|
|
||||||
global.fetch = jest.fn(() =>
|
global.fetch = jest.fn(() =>
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
@@ -196,7 +199,7 @@ test('Fetches data and creates chart and table correctly', async () => {
|
|||||||
|
|
||||||
const data = await fetchData('service');
|
const data = await fetchData('service');
|
||||||
|
|
||||||
expect(global.fetch).toHaveBeenCalledWith('/daily_stats.json');
|
expect(global.fetch).toHaveBeenCalledWith(`/services/${currentServiceId}/daily-stats.json`);
|
||||||
expect(data).toEqual(mockResponse);
|
expect(data).toEqual(mockResponse);
|
||||||
|
|
||||||
const labels = Object.keys(mockResponse).map(dateString => {
|
const labels = Object.keys(mockResponse).map(dateString => {
|
||||||
@@ -225,7 +228,7 @@ test('handleDropdownChange updates DOM for individual selection', () => {
|
|||||||
<div class="chart-subtitle"></div>
|
<div class="chart-subtitle"></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="aria-live-account"></div>
|
<div id="aria-live-account"></div>
|
||||||
<div id="activityContainer" data-currentUserName="Test User"></div>
|
<div id="activityContainer" data-currentUserName="Test User" data-currentServiceId="12345"></div>
|
||||||
<div id="tableActivity">
|
<div id="tableActivity">
|
||||||
<h2 id="table-heading"></h2>
|
<h2 id="table-heading"></h2>
|
||||||
<table id="activity-table">
|
<table id="activity-table">
|
||||||
|
|||||||
Reference in New Issue
Block a user