mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-06-23 08:49:46 -04:00
removed socket io
This commit is contained in:
@@ -21,7 +21,7 @@ Object.defineProperty(HTMLElement.prototype, 'clientWidth', {
|
||||
beforeAll(done => {
|
||||
// Set up the DOM with the D3 script included
|
||||
document.body.innerHTML = `
|
||||
<div id="activityChartContainer">
|
||||
<div id="activityChartContainer" data-daily-stats="{{ daily_stats }}" data-daily_stats_by_user="{{ daily_stats_by_user }}">
|
||||
<form class="usa-form">
|
||||
<label class="usa-label" for="options">Account</label>
|
||||
<select class="usa-select margin-bottom-2" name="options" id="options">
|
||||
@@ -30,7 +30,7 @@ beforeAll(done => {
|
||||
<option value="individual">User Name</option>
|
||||
</select>
|
||||
</form>
|
||||
<div id="activityChart">
|
||||
<div id="activityChart" >
|
||||
<div class="chart-header">
|
||||
<div class="chart-subtitle">Service Name - Last 7 Days</div>
|
||||
<div class="chart-legend" aria-label="Legend"></div>
|
||||
@@ -124,43 +124,3 @@ test('Check HTML content after chart creation', () => {
|
||||
expect(container.querySelector('svg')).not.toBeNull();
|
||||
expect(container.querySelectorAll('rect').length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
|
||||
test('Initial fetch data populates chart and table', done => {
|
||||
const mockData = {
|
||||
'2024-07-01': { sms: { delivered: 50, failed: 5 } },
|
||||
'2024-07-02': { sms: { delivered: 60, failed: 2 } },
|
||||
'2024-07-03': { sms: { delivered: 70, failed: 1 } },
|
||||
'2024-07-04': { sms: { delivered: 80, failed: 0 } },
|
||||
'2024-07-05': { sms: { delivered: 90, failed: 3 } },
|
||||
'2024-07-06': { sms: { delivered: 100, failed: 4 } },
|
||||
'2024-07-07': { sms: { delivered: 110, failed: 2 } },
|
||||
};
|
||||
|
||||
const socket = {
|
||||
on: jest.fn((event, callback) => {
|
||||
if (event === 'daily_stats_update') {
|
||||
callback(mockData);
|
||||
done();
|
||||
}
|
||||
}),
|
||||
emit: jest.fn(),
|
||||
};
|
||||
window.io = jest.fn(() => socket);
|
||||
|
||||
document.dispatchEvent(new Event('DOMContentLoaded'));
|
||||
|
||||
setTimeout(() => {
|
||||
const table = document.getElementById('weeklyTable');
|
||||
expect(table).toBeDefined();
|
||||
|
||||
const rows = table.getElementsByTagName('tr');
|
||||
expect(rows.length).toBe(8);
|
||||
|
||||
const firstRowCells = rows[1].getElementsByTagName('td');
|
||||
console.log('First row cells:', firstRowCells);
|
||||
expect(firstRowCells[0].textContent).toBe('07/01/24');
|
||||
expect(firstRowCells[1].textContent).toBe('50');
|
||||
expect(firstRowCells[2].textContent).toBe('5');
|
||||
}, 100);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user