mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-08 08:28:15 -04:00
fixing console errors
This commit is contained in:
@@ -25,10 +25,10 @@
|
|||||||
|
|
||||||
// Ensure the width is set correctly
|
// Ensure the width is set correctly
|
||||||
if (width === 0) {
|
if (width === 0) {
|
||||||
console.error('Chart container width is 0, cannot set SVG width.');
|
throw new Error('Chart container width is 0, cannot set SVG width.');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
svg.attr("width", width).attr("height", height);
|
svg.attr("width", width).attr("height", height);
|
||||||
|
|
||||||
var x = d3.scaleLinear()
|
var x = d3.scaleLinear()
|
||||||
|
|||||||
@@ -182,14 +182,14 @@ test('Handles zero width chart container', () => {
|
|||||||
// Set chart container width to 0
|
// Set chart container width to 0
|
||||||
Object.defineProperty(document.getElementById('totalMessageChartContainer'), 'clientWidth', { value: 0 });
|
Object.defineProperty(document.getElementById('totalMessageChartContainer'), 'clientWidth', { value: 0 });
|
||||||
|
|
||||||
|
try {
|
||||||
// Call the function to create the chart
|
// Call the function to create the chart
|
||||||
window.createTotalMessagesChart();
|
window.createTotalMessagesChart();
|
||||||
|
} catch (error) {
|
||||||
// Check if the console error was called
|
// Check if the error message is as expected
|
||||||
expect(consoleSpy).toHaveBeenCalledWith('Chart container width is 0, cannot set SVG width.');
|
expect(error.message).toBe('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