All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 13m30s
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
// src/components/Footer.test.tsx
|
|
import React from 'react';
|
|
import { screen } from '@testing-library/react';
|
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
import { Footer } from './Footer';
|
|
import { renderWithProviders } from '../tests/utils/renderWithProviders';
|
|
|
|
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
|
|
renderWithProviders(<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'));
|
|
renderWithProviders(<Footer />);
|
|
expect(screen.getByText('Copyright 2025-2030')).toBeInTheDocument();
|
|
});
|
|
});
|