ensure mocks are used wherever possible, more test fixes
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 1h7m5s

This commit is contained in:
2025-12-20 15:33:08 -08:00
parent bf4646fbe5
commit 56981236ab
48 changed files with 1200 additions and 499 deletions

View File

@@ -0,0 +1,35 @@
// src/components/Footer.test.tsx
import React from 'react';
import { render, screen } from '@testing-library/react';
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { Footer } from './Footer';
describe('Footer', () => {
beforeEach(() => {
// Set up fake timers to control the date
vi.useFakeTimers();
});
afterEach(() => {
// Restore real timers after each test
vi.useRealTimers();
});
it('should render the copyright notice with the correct year', () => {
// Arrange: Set a specific date for a predictable test outcome
const mockDate = new Date('2025-08-22T10:00:00Z');
vi.setSystemTime(mockDate);
// Act: Render the component
render(<Footer />);
// Assert: Check that the rendered text includes the mocked year
expect(screen.getByText('Copyright 2025-2025')).toBeInTheDocument();
});
it('should display the correct year when it changes', () => {
vi.setSystemTime(new Date('2030-01-01T00:00:00Z'));
render(<Footer />);
expect(screen.getByText('Copyright 2025-2030')).toBeInTheDocument();
});
});

11
src/components/Footer.tsx Normal file
View File

@@ -0,0 +1,11 @@
// src/components/Footer.tsx
import React from 'react';
export const Footer: React.FC = () => {
const currentYear = new Date().getFullYear();
return (
<footer className="text-center text-xs text-gray-500 dark:text-gray-400 py-4">
Copyright 2025-{currentYear}
</footer>
);
};