Files
work-club-manager/frontend/src/components/__tests__/shift-card.test.tsx

56 lines
1.6 KiB
TypeScript
Raw Normal View History

import { describe, it, expect } from 'vitest';
import { render, screen } from '@testing-library/react';
import { ShiftCard } from '../shifts/shift-card';
describe('ShiftCard', () => {
it('shows capacity correctly (2/3 spots filled)', () => {
render(
<ShiftCard
shift={{
id: '1',
title: 'Test Shift',
startTime: new Date(Date.now() + 100000).toISOString(),
endTime: new Date(Date.now() + 200000).toISOString(),
capacity: 3,
currentSignups: 2,
}}
/>
);
expect(screen.getByText('2/3 spots filled')).toBeInTheDocument();
});
it('disables sign-up button when full', () => {
render(
<ShiftCard
shift={{
id: '1',
title: 'Full Shift',
startTime: new Date(Date.now() + 100000).toISOString(),
endTime: new Date(Date.now() + 200000).toISOString(),
capacity: 3,
currentSignups: 3,
}}
/>
);
expect(screen.getByText('3/3 spots filled')).toBeInTheDocument();
expect(screen.queryByRole('button', { name: 'Sign Up' })).not.toBeInTheDocument();
});
it('shows "Past" badge and no sign-up button for past shifts', () => {
render(
<ShiftCard
shift={{
id: '1',
title: 'Past Shift',
startTime: new Date(Date.now() - 200000).toISOString(),
endTime: new Date(Date.now() - 100000).toISOString(),
capacity: 3,
currentSignups: 1,
}}
/>
);
expect(screen.getByText('Past')).toBeInTheDocument();
expect(screen.queryByRole('button', { name: 'Sign Up' })).not.toBeInTheDocument();
});
});