mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 17:45:32 -04:00
fix activity jtest test
This commit is contained in:
@@ -140,7 +140,6 @@ test('Initial fetch data populates chart and table', done => {
|
|||||||
const socket = {
|
const socket = {
|
||||||
on: jest.fn((event, callback) => {
|
on: jest.fn((event, callback) => {
|
||||||
if (event === 'daily_stats_update') {
|
if (event === 'daily_stats_update') {
|
||||||
console.log('Mock data:', mockData);
|
|
||||||
callback(mockData);
|
callback(mockData);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,6 +174,23 @@ test('SVG bars are created and animated correctly', done => {
|
|||||||
}, 1500); // Duration of the animation + buffer time
|
}, 1500); // Duration of the animation + buffer time
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Test to check console error when chart container width is 0
|
||||||
|
test('Handles zero width chart container', () => {
|
||||||
|
// Mock console.error
|
||||||
|
const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
|
|
||||||
|
// Set chart container width to 0
|
||||||
|
Object.defineProperty(document.getElementById('totalMessageChartContainer'), 'clientWidth', { value: 0 });
|
||||||
|
|
||||||
|
// Call the function to create the chart
|
||||||
|
createTotalMessagesChart();
|
||||||
|
|
||||||
|
// Check if the console error was called
|
||||||
|
expect(consoleSpy).toHaveBeenCalledWith('Chart container width is 0, cannot set SVG width.');
|
||||||
|
|
||||||
|
consoleSpy.mockRestore();
|
||||||
|
});
|
||||||
|
|
||||||
test('Creates chart on DOMContentLoaded', () => {
|
test('Creates chart on DOMContentLoaded', () => {
|
||||||
const createTotalMessagesChartSpy = jest.spyOn(window, 'createTotalMessagesChart');
|
const createTotalMessagesChartSpy = jest.spyOn(window, 'createTotalMessagesChart');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user