// 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();
// 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();
expect(screen.getByText('Copyright 2025-2030')).toBeInTheDocument();
});
});