From 933348baa5d473ed1391b19978b520e1c52520a6 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Thu, 23 Jan 2025 13:24:11 -0800 Subject: [PATCH] Fix jest --- tests/javascripts/activityChart.test.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/javascripts/activityChart.test.js b/tests/javascripts/activityChart.test.js index 3c6f20f3b..168e69c62 100644 --- a/tests/javascripts/activityChart.test.js +++ b/tests/javascripts/activityChart.test.js @@ -40,7 +40,7 @@ beforeAll(done => {
-
+
`; @@ -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-07': { sms: { delivered: 110, failed: 2, pending: 3 } }, }; + const tableContainer = document.getElementById('activityContainer'); + const currentServiceId = tableContainer.getAttribute('data-currentServiceId'); + global.fetch = jest.fn(() => Promise.resolve({ @@ -196,7 +199,7 @@ test('Fetches data and creates chart and table correctly', async () => { 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); const labels = Object.keys(mockResponse).map(dateString => { @@ -225,7 +228,7 @@ test('handleDropdownChange updates DOM for individual selection', () => {
-
+